wpsl_admin_js_settings

  1. Description
  2. Parameters
  3. Usage
  4. Changelog
  5. Source File
  6. Related

Description

This filter allows you to modify the default map settings used in wpsl-admin.js.

The plugin prints these settings on the Store Locator admin pages as the wpslSettings JavaScript object. They are used by the map on the store edit screen, the maps on the settings pages, Marker Studio, and the onboarding wizard.

The default map location comes from the “Start location” on Store Locator > Settings > Map. See the Map settings. Change the start location there first if you want the same location on the store locator page. Use this filter if you only want a different location or zoom level in the admin.

Parameters

$js_settings - (array) Settings used in wpsl-admin.js.

These are the keys you are most likely to change:

KeyDefaultDescription
defaultLatLngThe coordinates of the "Start location" setting, or '37.4220, -122.0840' when there are noneThe location the admin maps show when there is no other location to show, for example for a new store without coordinates.
defaultZoom6The zoom level the admin maps start with.
apiThe active map providerAn array with the provider (gmaps, mapbox, osm or stadia) and its key, language, region, style and tile layer settings, as set on Store Locator > Settings > API.
geocodeComponentsOnly set when "Country filtering" is set to "Restrict results (hard)" with one countryGoogle Maps only. Restricts the geocode requests on the store edit screen, and in the geocode test on the settings page, to that country, for example array( 'country' => 'NL' ).

To see all the keys, open a Store Locator admin page in your browser and type wpslSettings in the console.

Usage

This example changes the default map coordinates and zoom level for the store map preview:

add_filter( 'wpsl_admin_js_settings', 'custom_admin_js_settings' );
function custom_admin_js_settings( $js_settings ) {
$js_settings['defaultLatLng'] = '51.507351, -0.127758';
$js_settings['defaultZoom'] = 8;
return $js_settings;
}

If you want to change the default map location, but you don’t know the coordinates, then you can use a site like http://www.latlong.net/ to find them.

Changelog

VersionDescription
3.0Moved to includes/admin/assets/class-resources.php. Added the api key with the active map provider and its settings. The settings are now also used by Marker Studio and the onboarding wizard. Without a start location, defaultLatLng now falls back to '37.4220, -122.0840' instead of Amsterdam. geocodeComponents is now set by the "Country filtering" setting.
2.0Introduced.

Source File

This filter is located in /includes/admin/assets/class-resources.php.

Placement

The code needs to be placed in the functions.php file inside your active theme folder.