繁体   English   中英

标记完成加载后是否有回调?

[英]Is there a callback for markers when they finished to load?

我找不到任何地方,无论是在文档中,当标记完成加载到地图上时的回调。

我没有在文档上找到任何其他方法,也没有找到关于如何解决“在谷歌地图中加载所有标记时的回调或事件”的答案,所以我想分享我使用的这个技巧:

  1. 创建一个加载器

  2. 设置您想要的缩放比例,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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM