Can we access the Store Locator's map information?

Yes. Brands using the store locator will often want to be able to display extra information on the same page as the store locator depending on the geo-location of the map (or the site visitor). The store locator will broadcast "events" containing information about it's current location to the HTML page in which it is embedded. In order to "listen" for these events, just add an event listener to the page:

window.addEventListener("LOCALLY_region_update", function(event) {
    // event.detail will contain an object will all location-related details
    // act upon event.detail here ...
}, false);


A sample event.detail output:

{
    city: "Violet"
    code: "70092"
    country: "US"
    distance: 2.2720858189893
    distance_km: 3.6565676802756
    lat: "29.90219300"
    lng: "-89.89726000"
    region: "LA"
    state: "LA"
    zip: "70092"
}


You can also get information about stores that your users have clicked on via this event listener:

window.addEventListener("LOCALLY_store_click", function(event) {
    // event.detail will contain an object will all location-related details
    // act upon event.detail here ...
}, false);


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.