How to make a popup automatically appear after zoom?

Thank you for your interest in our JavaScript Hooks and APIs. With our tools, you can easily make your map automatically show a popup when a user clicks a state. Here's how to do it:

Copy and paste the following script into your HTML document:

<script>
simplemaps_usmap.mapdata.main_settings.popups = 'on_click';
simplemaps_usmap.mapdata.main_settings.all_states_zoomable = 'yes';
var last_zoomed = '';
simplemaps_usmap.hooks.zoomable_click_state = function(id) {
  last_zoomed = id;
}
simplemaps_usmap.hooks.zooming_complete = function() {
  if (simplemaps_usmap.zoom_level == 'state' && last_zoomed) {
    simplemaps_usmap.popup('state', last_zoomed);
  }
}
</script>

That's it! Your map will now display a popup with custom content when a user clicks on a state. For more information on our JavaScript Hooks and APIs, please visit our documentation pages:

If you have any questions or need further assistance, our customer support team is always here to help. Please don't hesitate to reach out to us.