Hi there,

I'm currently designing a website for a client and that have requested a search form for the store locator on the home page. I was wondering if it is possible to have a search form on a different page to the store locator. It should be just the same as the one from the panel. It would just redirect to the store locator page a feed the locator with the entered address.

Would someone let me know if this is possible? or suggest some solution for me

Thanks in advanced

Justin

Comments

justinf111’s picture

Version: 7.x-1.0-beta2 » 7.x-1.0-rc1
justinf111’s picture

Category: support » feature
Priority: Normal » Major
justinf111’s picture

I have got it so on all pages I have a search form that the user will enter in the post code. Then it stores that value as a cookie and it then retrieved on the store locator page although I'm unsure of how to submit the value so that the google map will update the location.

Please help as I need this working for a client asap

Thanks

michfuer’s picture

Priority: Major » Normal
Status: Active » Closed (works as designed)

Separating the Map and panel is going to be difficult. The panel requires a storeLocator.View to bind with and that view is generated in the google_store_locator.js on page load. Also dealing with events such as clicking a store in the panel would be unusual.

I think your method of grabbing the postal code from a search form is the easiest option. You could add the postal code to the location-search input using jQuery, something like:

$('.location-search input', '.google-store-locator-map-container').val(ZIP_CODE);

The user will still have to click inside the location-search element and hit enter to activate the map search. If you wanted to automate this you could send a flag variable along with the ZIP_CODE so you know they're coming from the search form, then trigger a submit on location-search once the map has fully loaded (again using the jQuery functions .load() and .trigger())

At the moment I don't think there's enough demand for this type of functionality to create an "out of the box" feature.

michaelhaberle’s picture

Nobody is asking for it? That's weird. It's a super common (and widely-used) feature :)

I've been working on getting it to function today.

So far it isn't going too well.

Here's my hacky code full of redundant ways to try to get it to submit:

<?php
	if(isset($_REQUEST['s-store-zip']) && $_REQUEST['s-store-zip']!="") {
		$zipSent = $_REQUEST['s-store-zip'];
	}
		
	if($zipSent != "") {
?>
<script>
 jQuery(document).ready(function(){
	jQuery('.location-search input', '.google-store-locator-map-container').val('<?php echo $zipSent; ?>');
	
	
	var press = jQuery.Event("keypress");
	press.ctrlKey = false;
	press.which = 13;
	
	setTimeout(
		function() 
			{
				jQuery('.location-search input').trigger('click');
				jQuery('.location-search input').val('20191');
				jQuery('.location-search input', '.google-store-locator-map-container').trigger(press);
				jQuery().trigger(jQuery.Event('keypress', {which: 13}));
				jQuery().trigger(jQuery.Event('keydown', {which: 13}));
				jQuery().trigger(jQuery.Event('keyup', {which: 13}));
				jQuery('form .storelocator-filter').submit() ;
				
			}, 5000);
});

jQuery(document).load(function(){
	jQuery('form .storelocator-filter').delay(5000).submit() ;
});
</script>
<?php	
}
?>

So far it's just not working though.

swim’s picture

Sorry for the late reply but you could achieve this functionality by extending Drupal.behaviors.googleStoreLocator.

  searchtext = new Array();
  if (typeof urlParams.postcode != 'undefined' && urlParams.postcode != '' && 
  urlParams.postcode.toLowerCase() != 'input  postcode')  {
    searchtext.push(urlParams.postcode);
  }
  if (typeof urlParams.state != 'undefined') {
    searchtext.push(urlParams.state);
  }
  if (searchtext != '') {
    searchtext.push('Australia');
    searchtext = searchtext.join(' ');
    console.log('do search '+searchtext);
    locator.panel.searchPosition(searchtext);
  }
  $('.location-search input').val(searchtext);

Accepting a url argument of postcode & state. Simple example but can easily be adapted.

pepsimxm’s picture

Hi michaelhaberle,

Did you ever figure out how to submit the form without pressing enter?

Currently on day 3 of trying to figure this one out :)

Thanks

srikanthgdk_drupal’s picture

Hi,

Even I am searching for the apt solution to get the location details from the URL which is submitted from other page having a textbox and submit button and should search the location in our store locator panel and should be marked in the map. As simple as the functionality should work as it is by getting the data from the URL.

And the location search box should work on submitting a button tried to trigger keyup event on button click but no use.
PLease help me on this.

Thanks,
Srikanth

Nancy_Goyal’s picture

Issue summary: View changes

Hi

I also need this feature to implement. I have tried this by jQuery but unable to submit the view form to get the desired results. Please help.