With Agile Store Locator users have multiple options on how their visitors’ current location may or may not be detected. Moreover, detecting a location is done with a geolocation prompt that appears when the map is loaded. Furthermore, these options can be either selected or a shortcode can be added to bring about the change.
The options for geolocation prompts that are listed in “ASL Settings” include:
- NONE – Effectively disables the geolocation prompt so users will not be prompted to provide their current location.
The corresponding shortcode is the following:
[ASL_STORELOCATOR prompt_location="0"]
2. GEOLOCATION DIALOG– Enables a geolocation prompt that will detect your current location. Therefore, users simply need to click “USE LOCATION” on the prompt and their location will be detected.
The corresponding shortcode is the following:
[ASL_STORELOCATOR prompt_location="1"]
- TYPE YOUR LOCATION Dialog – Prompts users to manually type in their location in the address bar and click on “LOCATE” to detect your location. In addition, the address bar is embedded with Google Place API so a list of addresses will drop down for the user to choose from.
The corresponding shortcode is the following:
[ASL_STORELOCATOR prompt_location="2"]
- GEOLOCATION WITHOUT DIALOG – Detection of your location upon page load without giving you a geolocation popup. However, this only works with secure HTTPS connections. Furthermore, some users may encounter an error with this option as shown in the below image. If this error does occur, all you need to do is go to preferences and select the “Always allow…” option. The corresponding shortcode is the following:
[ASL_STORELOCATOR prompt_location="3"]
Why is Geolocation Not Working? #
Sometimes users might come across a situation where the geolocation feature will not work.
The main reason why the geolocation feature does not work is if “Block” is selected instead of “Allow” on the “geolocation prompt”. Moreover, the selection will be saved in the browser preferences.
The solution is to go to your browser “Preferences” and allow geolocation to be used.
GEOJS API Service #
GEOJS is a free API service that is recently included in the Store Locator to locate your GeoLocation, Agile Store Locator is not responsible for its accuracy and results as it is a third-party API, it works based on the IP of the user to geo-locate his position.
How can we hook the GeoLocation functionality to a Custom button? #
Agile Store Locator has a load event in the JS hooks that can be used to hook geolocation to a custom button as given below.
<script type="text/javascript">
function asl_event_hook(_event) {
if(_event.type == 'init') {
// You can replace my-custom-button-class with your own class for the button
jQuery('.my-custom-button-class').bind('click', function(e) {
// initiate geolocation
asl_view.geolocate_();
});
}
}
</script>
The following script needs to be added on the page where the store locator is rendering, so it will link the event to the class with the jQuery click, in the example above my-custom-button-class
is the class being used.