Set a Custom Zoom Level for the Single Store Pages

The zoom level of the map on a single store page is normally based on the “Initial zoom level” option on the Map settings page. That’s the same zoom level the store locator starts with. To use a different zoom level on the store pages, use the wpsl_map_shortcode_defaults filter. You don’t need a custom store page template for this.

The code below sets the zoom level to 16 on the store pages only. Maps made with the [wpsl_map] shortcode on other pages keep using the setting. Place it in the functions.php inside your active theme folder.

add_filter( 'wpsl_map_shortcode_defaults', 'custom_store_page_zoom' );
function custom_store_page_zoom( $defaults ) {
// Only change the zoom level of the map on the store pages.
if ( is_singular( 'wpsl_stores' ) ) {
$defaults['zoom'] = 16;
}
return $defaults;
}

Any value between 1 (the whole world) and 21 (street level) works; around 15 to 17 shows the streets around the store. If you already use a custom store page template, you can also set the zoom level on the shortcode in that template, for example [wpsl_map zoom="16"]. A zoom attribute on the shortcode always takes priority over the filter.

On Mapbox maps, the zoom level is ignored when “Auto adjust the zoom level to make sure all markers are visible?” is enabled on the Map settings page. The map then zooms in to the “Max auto zoom level” instead, so set that option to the zoom level you want, or disable the auto adjust option.