admin管理员组文章数量:1313177
Looking to utlize the spiderfy which George MacKerron has developed. However I have one other requirement which is to load the map with all markers "spiderd" out by default. I can mimic this by using javascript to click on the markers, but there has to be another way by using the spiderfy code. Has anyone acplished this?
var map = new google.maps.Map(document.getElementById("map-canvas"), options);
var iw = new google.maps.InfoWindow();
var oms = new OverlappingMarkerSpiderfier(map, {keepSpiderfied: true});
/
Looking to utlize the spiderfy which George MacKerron has developed. However I have one other requirement which is to load the map with all markers "spiderd" out by default. I can mimic this by using javascript to click on the markers, but there has to be another way by using the spiderfy code. Has anyone acplished this?
https://github./jawj/OverlappingMarkerSpiderfier#overlapping-marker-spiderfier-for-google-maps-api-v3
var map = new google.maps.Map(document.getElementById("map-canvas"), options);
var iw = new google.maps.InfoWindow();
var oms = new OverlappingMarkerSpiderfier(map, {keepSpiderfied: true});
http://jsfiddle/vFAy6/5/
Share Improve this question edited Jan 8, 2014 at 16:56 user3032973 asked Jan 8, 2014 at 15:27 user3032973user3032973 4152 gold badges10 silver badges26 bronze badges3 Answers
Reset to default 5I came up with a solution that worked for me. After I've added all markers, I set a timeout to call a functiont to open each cluster and in the OMS js.
- keepSpiderfied keeps all spideried markers open. It wasn't working for me so I altered the OMS js. If it works for you, you don't need to change this.
Find this:
(!e||!this.keepSpiderfied)&&this.unspiderfy();
Replace with this:
(!e||!this.keepSpiderfied);
function to call to open each cluster group:
function openAllClusters() { var markers = oms.markersNearAnyOtherMarker(); $.each(markers, function (i, marker) { google.maps.event.trigger(markers[i], 'click'); }); }
I set a timeout after I added my last marker (because it didn't work just calling the function immediately after):
setTimeout(openAllClusters, 2000);
From the documentation:
keepSpiderfied (default: false)
By default, the OverlappingMarkerSpiderfier works like Google Earth, in that when you click > a spiderfied marker, the markers unspiderfy before any other action takes place.
Since this can make it tricky for the user to work through a set of markers one by one, you > can override this behaviour by setting the keepSpiderfied option to true.
According to the developer of this google map extension this will not work.
https://github./jawj/OverlappingMarkerSpiderfier/issues/2
本文标签: javascriptGoogle Maps Spiderfy open by defaultStack Overflow
版权声明:本文标题:javascript - Google Maps Spiderfy open by default - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741925151a2405237.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论