Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

× Ideal Store Locator Plugin (iStoreLocator) works with Google Maps API which allows your website visitors to easily locate stores/contacts on the map.

Product Page

Different iStoreLocator behavior depend on external POST

6 years 2 weeks ago #24006 by brandnew
Hi.

This is my first post, so I have to say, that iStoreLocator is a great plugin that follow to my demand in 99% :)
But, just like in life, the more you have, the more you want ;)

My customer is local (half million city) groceries network - about 60 shops.
On just projected new webpage there is a page with iStoreLocator map.
This map should display all shops in this city, when this page is visited without "context".
So we disable automatic geolocation and set display radius to 15 km.
And this is great.

1. First fancy scenario
But on all rest pages there is pinned button - find the nearest shops.
And we want to go to page with iStoreLocator map but with posted two "context" directives:
- change display radius to 3 km;
- "push" Find my location button, when the page and map is ready.
We know how to post data and catch them in PHP on page with iStoreLocator and we know also how to change list selection and emulate click in jQuery.
What we need to know, is how to catch iStoreLocator fully loaded event.

2. Second fancy scenario
Pinned button described above, may also have enter your location input box.
We know how to use Google autocomplete features and how to send it result to webpage with iStoreLocator.
What is interesting, this value is automatically populated to Enter location field above iStoreLocator Google Map.
But, in this case, we would like add some "context" on that situation:
- change display radius to 3 km;
- trigger autocomplete event on Enter location field, as if it was selected by the user.
What we need to know, is how to catch iStoreLocator fully loaded event and how to trigger that event.

Is this is possible?

Best regards,
Brand New

p.s. English is not my native language, so please forgive me if I make terrible mistakes.

Please Log in or Create an account to join the conversation.

6 years 2 weeks ago #24007 by support
Greetings,

For both scenarios:
When you change the range (max distance) select list iStoreLocator will automatically refresh the map with the range changes, I haven't tested but you probably can trigger the change using jQuery( document ).ready();

First scenario:
We haven't planned any event to be triggered after iStoreLocator is loaded, so right now I'm not sure how to easily achieve this without custom work.

Second scenario:
As long as the Auto Geolocation is disabled you can add an "address" variable to your URL. Example: yourdomain.tld/locations.html?address=some+address

Will that work for you?

Let us know if you need any further assistance.

Best regards,
The following user(s) said Thank You: brandnew

Please Log in or Create an account to join the conversation.

6 years 1 week ago #24008 by brandnew
Hello Douglas.

Thank You for fast reply.

I found workaround to check if iStoreLocator is completely loaded.
I check in loop presence of one of the last(?) inserted DOM element, counter of location found.
This is maybe not elegant solution, but works!

1. Finally I found solution for first fancy scenario.
When PHP detect POST with certain value (b.e. doGeo = 1) javascript/jQuery is injected:
jQuery( document ).ready(function() {
var isReady = setInterval(function(){ checkReady() }, 200);
function checkReady() {
if(jQuery("#isl-search-result .label").length){
jQuery("#maxdistance").val(3);
jQuery(".isl-geolocate-btn").trigger( "click" );
clearInterval(isReady);
}
}
});

And this works as hell :)

2. But second scenario is a huge problem.
I can detect iStoreLocator is completely loaded (by described above workaround).
I can change search radius then (but this not trigger any event).
I can populate accurate search result from Google Maps Autocomplete to "isl-location-search" search box.

But I cannot trigger iStoreLocator to consider these values and recalculate search result.
In "normal", raw Google Maps environment, I can do that by code like this:
"google.maps.event.trigger(autocomplete, 'place_changed');"
But I totally don't know how to manipulate iStoreLocator object(?) and how force it to trigger 'place_changed' event.
I found that type of listener inside jquery.ui.map.storelocator.min.js (line 418) but this is end.

And for now this is the challenge...

Can You help to come closer to solution?
Thank You in advance :)

Best regards,
Brand New

Please Log in or Create an account to join the conversation.

6 years 1 week ago #24009 by support
Greetings,

2. You must trigger the change event.
jQuery('#maxdistance').val(100).trigger('change');

Best regards,

Please Log in or Create an account to join the conversation.

6 years 1 week ago #24018 by brandnew
Hello Douglas.

Thank You for hint - this may trigger right event.

But, function that change display radius on change event need also origin longitude and latitude.
$('#maxdistance').on('change',function(){
                if(self.options.origin.lat && self.options.origin.lng){
                    self.getData(self.options.origin);
                }
            });
- jquery.ui.map.storelocator.min.js line 700

You can check this on iStoreLocator demo page - without address from geolocation or autocomplete - changing radius not change map display.

In my case problem is, how to trigger event, that "tell" to autocomplete - input data was changed (injected from POST/cookie), try to "translate" it to longitute and latitude.
I found function that listen to this, but I don't know how to fire it from outside of gmap(?) object.
autocomplete.addListener('place_changed', function() {
//there is code that made what I need to be done
 
});'
- jquery.ui.map.storelocator.min.js line 418

Best regards,
Brand New

Please Log in or Create an account to join the conversation.

6 years 1 week ago #24024 by support
Greetings,

I'm working on a few changes in order to help you out, however it will work the Search, not the Place Search.

You'll be able to search using this code;
var options = {};
options.address = 'Berlin'; // Any location address.
jQuery('#iStoreLocator').gmap('search',options);

I'll send a file to your email address in a few minutes.

Best regards,

Please Log in or Create an account to join the conversation.

6 years 1 week ago #24026 by brandnew
Hello Douglas.

Thanks again for fast and accurate help.

Everything works fine and as expected.
The final code to set address and trigger latitude and longitude update is:
jQuery( document ).ready(function() {
var isReady = setInterval(function(){ checkReady() }, 200);
function checkReady() {
if(jQuery("#isl-search-result .label").length){
var searchedPlace = jQuery("#iStoreLocator-location-search").val(); //get value from autopopulated field, but there may be also PHP POST value
var options = {};
options.address = searchedPlace;
jQuery('#iStoreLocator').gmap('search',options);
jQuery("#maxdistance").val(3).trigger("change");
clearInterval(isReady);  
}
}
});

In my version of component, that You sent me yesterday (many, many thanks :) ) iStoreLocator Id is without these random numbers, b.e. iStoreLocator_1666316870.
I think You done this to simplify gmap object addressing.
But meanwhile I found solution to get it, even if it is not simplified.
var islId = jQuery(".isl_container div[id^='iStoreLocator_']").attr('id');
And from now we can manipulate this to address other objects.
b.e. jQuery('#' + islId + '-location-search') <- search field DOM object
jQuery('#' + islId + '_btn_geolocate') <- geolocate button DOM object

Best regards,
Brand New

Please Log in or Create an account to join the conversation.

6 years 1 week ago #24030 by support
@Brand New

I'm glad it is working as you wished for! ;-)

I'll keep the customizations I made for you in the next version, so you will be able to upgrade without any issue.

Best regards,

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback