【发布时间】:2017-06-07 07:56:33
【问题描述】:
我正在使用 Angular Google Maps 加载 Google Maps API,但加载 API 脚本时会有 3-4 秒的暂停。因此页面上的所有内容都已加载-> 3-4 秒暂停-> API 脚本开始加载-> 地图显示。
谷歌地图配置 sn-p:
uiGmapGoogleMapApiProvider.configure({
key: 'xxxxxxxxxx',
v: '3',
libraries: 'geocoder',
preventLoad: false,
china: false,
transport: 'https'
});
地图在这里加载:
<div id="shopMap" ng-init="initShopMap()"></div>
通过这个函数:
$scope.initShopMap = function() {
if ($scope.shop.latitude && $scope.shop.longitude) {
uiGmapGoogleMapApi.then(function(maps) {
shopMap = new maps.Map(document.getElementById("shopMap"), {
control: {},
options: {
draggable: true,
scrollwheel: false
},
center: new maps.LatLng(0, 0),
zoom: 14,
marker: {
options: {
icon: {
scaledSize: { width: 24, height: 36 },
url: '/images/pm-shop-icon.png'
}
}
}
});
directionsService = new maps.DirectionsService();
initMarkers();
$scope.showShopMap = true;
});
}
}
任何想法为什么会发生这种延迟?非常感谢任何提示,谢谢✨
【问题讨论】:
标签: javascript angularjs google-maps google-maps-api-3