Using query string parameters with the jQuery Store Locator


Warning: Invalid argument supplied for foreach() in /home/customer/www/bjornblog.com/public_html/wp-content/plugins/gravityforms/form_display.php on line 1726

Warning: Invalid argument supplied for foreach() in /home/customer/www/bjornblog.com/public_html/wp-content/plugins/gravityforms/form_display.php on line 473

Since version 2.0.0 of the jQuery Store Locator plugin I’ve included an option to handle query string parameters but I haven’t provided many details on how to take advantage of it. I thought I would take the time to provide an example so people aren’t stuck having to dig through the plugin code to understand how to use this option. The primary use for using query string parameters with the plugin would be to set up a search and display the results on a different page.

  • The first step in using query string parameters is to set the ‘querystringParams’ and ‘fullMapStart’ plugin options to true.
  • The next step would be to set up the search form with the method set to “get” and the action set to your store locator page along with your normal form inputs (address and/or name search fields). So, the form HTML would look something like this instead of the default:
<form id="bh-sl-user-location" method="get" action="/storelocator">
 <div class="form-input">
  <label for="bh-sl-address">Enter Address or Zip Code:</label>
  <input type="text" id="bh-sl-address" name="bh-sl-address" />
 </div>

 <button id="bh-sl-submit" type="submit">Submit</button>
</form>
  • If you don’t want to use a form, all you have to do is set up your URL with query string parameters that match the “addressID” and/or “searchID” settings. For example, if you’re using the default settings for the addressID and your store locator is on the /storelocator page, a URL would look like:

http://yourdomain.com/storelocator?bh-sl-address=Edina,MN

  • If you’ve got the “nameSearch” option set to true you can also use that ID as another parameter. For example:

http://yourdomain.com/storelocator?bh-sl-search=Chipotle

  • If you’re using the maxDistance option you can also use that ID as a parameter in version 2.0.8 up. For example:

http://yourdomain.com/storelocator?bh-sl-address=Edina,MN&bh-sl-maxdistance=20

There was a problem with your submission. Please review the fields below.