我找不到任何地方,无论是在文档中,当标记完成加载到地图上时的回调。
我没有在文档上找到任何其他方法,也没有找到关于如何解决“在谷歌地图中加载所有标记时的回调或事件”的答案,所以我想分享我使用的这个技巧:
创建一个加载器
设置您想要的缩放比例,gmap 会认为您移动了它
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.600486, lng: 9.261252},
zoomControl: true,
zoom: 8,
...draw your pins and then set them normally in the map
markerClusterer = new MarkerClusterer(map, markers, mcOptions);
...now fake a zoom
google.maps.event.addListenerOnce(map,
'zoom_changed',
function(event) {
console.log("All your markers are loaded");
// remove the loader
});
map.setZoom(8);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句