Skip to content

Instantly share code, notes, and snippets.

@carmoreira
Created March 5, 2021 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carmoreira/20d5d20cb6e48762a6320ac99ff0f011 to your computer and use it in GitHub Desktop.
Save carmoreira/20d5d20cb6e48762a6320ac99ff0f011 to your computer and use it in GitHub Desktop.
Create Button to clear content that displays after map is clicked - Interactive Geo Maps
// this assumes there's at least one element on the page with the class clear_map_info
document.querySelectorAll('.clear_map_info').forEach(
function(button) {
button.addEventListener('click', function(event) {
// If the clicked element doesn't have the right selector, bail
if (!event.target.matches('.clear_map_info')) return;
// Don't follow the link
event.preventDefault();
// Clear map content action - CHANGE WITH YOUR MAP ID
iMapsActions.resetActions(15751);
}, false);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment