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 accomplished this?
https://github.com/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.net/vFAy6/5/
I 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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With