Spiderfying locations with same address
-
Markers with same address/latlong display on top of each other and users aren’t able to click between them. I have seen the other thread where you suggest to offset them so there is distance, but depends on the zoom levels, they may still be on top of each other.
Would you consider officially adding OverlappingMarkerSpiderfier (demo)? It separates (spiderfies) the markers that are overlapping. I modified WPSL 2.2.235 like below to get it working:
- Add OverlappingMarkerSpiderfier as a dependency of wpsl-gmap.js
- Modify wpsl-gmap.js like below:
After line 129 (
map = new google.maps.Map();
), add:oms = new OverlappingMarkerSpiderfier(map, { markersWontMove: true, markersWontHide: true, basicFormatEvents: true, keepSpiderfied: true, ignoreMapClick: true });
Add
oms
as a parameter to all location markers. For example, line 141 becomes:addMarker( latLng, mapData[index].id, mapData[index], false, infoWindow, oms );
Since we’re only adding
oms
to location markers and the starter marker also uses it, we make oms optional on line 1831 like so:function addMarker( latLng, storeId, infoWindowData, draggable, infoWindow, oms = null ) {
Change the click listener of the marker on Line 1869 like so:
google.maps.event.addListener( marker, "spider_click",( function( currentMap ) {
And after that chunk of listener above, add:
if(oms){ oms.addMarker(marker); // adds the marker to the spiderfier _and_ the map }
Let me know your thoughts. Thank you!
- The topic ‘Spiderfying locations with same address’ is closed to new replies.