Created
October 8, 2021 18:06
-
-
Save carmoreira/35c66c70dfad876d68b471fc043283e3 to your computer and use it in GitHub Desktop.
Toggle visibility of single marker when using dropdown or list in Interactive Geo Maps WordPress plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set map ID and default marker to display. | |
let mapID = 3485106; | |
let defaultMarker = 'Marker 01'; | |
let mapContainer = document.getElementById('map_' + mapID); | |
mapContainer.addEventListener('mapready', function(ev) { | |
let allMarkers = iMapsManager.getMarkersByValue(mapID, '*', 'id'); | |
let myMarker = iMapsManager.getMarkersByValue(mapID, defaultMarker, 'id'); | |
allMarkers.forEach(function(marker){ marker.hide(); }); | |
myMarker.forEach(function(marker){ marker.show(); }); | |
iMaps.maps[mapID].series[1].mapImages.each(function(marker) { | |
marker.events.on("hit", function(ev) { | |
allMarkers.forEach(function(amarker){ amarker.hide(); }); | |
ev.target.show(); | |
}, this); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment