Store Locator Javascript Automation API - Event Handlers

Support > API Integration > Store Locator Javascript Automation API - Event Handlers

Introduction


Our store locator has a powerful Javascript based API interface which includes Event Handlers. These are functions that are called if present on the page and can be used to notify other scripts that certain events have happened. For example:


  • The store locator has finished loading and is ready for use
  • The user has clicked on a link in the locator (useful for integration with Google Analytics for example)
  • A Filter or search distance was changed
  • The user conducted an Address or Geolocation search


If you declare a function matching the name of one of the functions listed below, the store locator will attempt to call that function and pass it relevant data (if applicable). For example, if I declare the following function on the page or in another script:


function storeLocatorClickEventHandler(eventData) {
   console.log(eventData);
}


This will be called each time a link, button or marker is clicked in the locator.


Event Handlers

function storeLocatorClickEventHandler(eventData) {
}

This event handler is called whenever a link, button or marker is clicked in the locator. eventData


eventData: (Object) information about the event such as what element was clicked and the store name the element is part of.


function storeLocatorDirectionsHandler(eventData) {
}

This event handler is called if the user clicks on a link or button to show Directions to a store location.


eventData: (Object) information about the event such as which store name was clicked.


function storeLocatorFilterChangeHandler(filters) {
}

This event handler is called whenever a filter is changed (either a checkbox is checked / unchecked or an item selected from the dropdown list).


filters: (Array) An array containing the names of the Filters that are currently selected


function storeLocatorListLocationsHandler(locations) {
}

This event handler is called whenever the store list changes.


locations: (Array) An array of stores in the store list


function storeLocatorListUpdateCompleteHandler(response) {
}

This event handler is called whenever the store list has completed updating.


response: (object) {

lat: (float) map latitude coordinate,

lng: (float) map longitude coordinate,

radius: (integer) search radius,

selectedFilters: (Array) selected filters,

loadType: (string) Can be one of: initial_load (the first time the locator loads) or location (if a location search took place)

}


function storeLocatorLoadCompleteHandler() {
}

This event handler is called when the locator has finished loading and is ready for use.


function storeLocatorMarkerClickHandler(store, marker) {
  return true | false;
}

This event handler is called whenever a map marker is clicked on.


store: (object) information about the store the marker is attached to

marker: (object) a reference to the map marker object


Important: return true to open the map popup window or false to do nothing


function storeLocatorSearchDistanceChangeHandler(searchRadius) {
}

This event handler is called whenever the search radius is changed.


searchRadius: (string or integer) the new search radius value - either 'Unlimited' or an integer number of miles or kms.


function storeLocatorSearchEventHandler(eventData) {
}

This event handler is called when the user either clicks on the 'My Location' button or searches for an address in the address or location search input fields.


eventData: (object) information about the event such as the address and map coordinates.


function storeLocatorSetLanguageHandler() {
}

This event handler is called when the store locator initializes and it should return the name of the language to display. This is required because changing the language requires a reload of the store data which would then overwrite any settings that had been applied after load time. You would normally call the public function storeLocatorReinitialize() to apply the language name change.


function storeLocatorShowMapPopupInfoEvent(store, storelocatorInfoWindow) {
}

This event handler is called whenever the map popup window is about to be displayed.


store: (object) information about the store the popup window related to

storelocatorInfoWindow (object) a reference to the infoWindow object (Google Maps only)


function storeLocatorStoreSelectedHandler(store) {
}

This event handler is called whenever a store is selected by either clicking on the store name in the store list or clicking on it's map marker.


store: (object) information about the store the popup window related to