jQuery Store Locator Plugin
I can’t believe it’s been over a year since I first published my Google Maps store locator JavaScript code. I’ve had several requests for an updated version and that post has definitely received more traffic than any of my others. I’ve finally created a new version of the locator using Google Maps API version 3 and this time I’ve turned it into a full-on jQuery plugin. I re-worked almost everything in the code but I don’t think I’m going to go through function by function like I did in the last post. jQuery should make this store locator much easier to implement and I’ve included several options. Without further ado, here is the full documentation for the plugin:
jQuery Google Maps Store Locator Plugin
Files can be downloaded from GitHub
This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information. How you create the data file is up to you. I originally created this for a company that didn’t have many locations, so I just used a static XML file. I also decided to geocode all the locations beforehand, to make sure it was quick and to avoid any potential geocoding errors. However, if you’re familiar with JavaScript you could easily make a modification to geocode everything on the fly (I may add this as an option at some point).
A note on the distance calculation: this plugin currently uses a distance function that was originally programmed by Chris Pietschmann. Google Maps API version 3 does include a distance calculation service (Google Distance Matrix API) but I decided not to use it because of the current request limits, which seem somewhat low. In addition, because the plugin currently calculates each location’s distance one by one, it appeared that I would have to re-structure some things to make all the distance calculations at once (or risk making many request for one location lookup). So, the distance calculation is “as the crow flies” instead of a road distance.
Handlebars is now required: It’s very important to note that the plugin now requires the Handlebars template engine. I made this change so that the data that’s displayed in the location list and the infowindows can be easily customized. I also wanted to separate the bulk of the layout additions from the main plugin file. Handlebars pretty slick, will read Mustache templates, and the built-in helpers can really come in handy. Depending on what your data source is, 2 of the 4 total templates will be used (KML vs XML or JSON) and there are options to set the paths of each template if you don’t want them in the default location. If you’re developing something for mobile devices the templates can be pre-compiled for even faster loading.
Options
The following options are available.
| Property | Default | Description |
| mapDiv | map | The div where the actual Google Map is displayed. |
| listDiv | loc-list | The div container around the location list. |
| formContainerDiv | form-container | The div container around the form. |
| formID | user-location | The ID of the input form. |
| inputID | address | The ID of the input field. |
| zoomLevel | 12 | The zoom level of the Google Map. Set to 0 to have the map automatically center and zoom to show all display markers on the map. |
| pinColor | fe7569 | The hex color of the makers (don’t use # if you override). |
| pinTextColor | 000000 | The text hex color of the markers (don’t use # if you override). |
| lengthUnit | m | The unit of length. Default is m for miles, change to km for kilometers. |
| storeLimit | 26 | The number of closest locations displayed at one time. |
| distanceAlert | 60 | Displays an alert if there are no locations with 60 miles of the user’s location. |
| dataType | xml | The format of the data source. Accepted values include kml, xml, json, and jsonp. |
| dataLocation | locations.xml | The path to the location data – XML is default but JSON is also an option. |
| listColor1 | ffffff | The hex background color of the odd list elements (don’t use # if you override). |
| listColor2 | eeeeee | The hex background color of the even list elements (don’t use # if you override). |
| originMarker | false | Display a marker at the origin. |
| originpinColor | blue | Sets the color of the origin marker. |
| bounceMarker | true | Bounces the maker when a list element is clicked. |
| slideMap | true | First hides the map container and then uses jQuery’s slideDown method to reveal the map. |
| modalWindow | false | Shows the map container within a modal window. Set slideMap to false and this option to true to use. |
| overlayDiv | overlay | The div that fills 100% of the window and fills with a transparent background image when the modal window option is used |
| modalWindowDiv | modal-window | The div container of the actual modal window |
| modalContentDiv | modal-content | The div container around the content of the modal window |
| modalCloseIconDiv | close-icon | The div that displays the close icon to close the modal window |
| defaultLoc | false | If true, the map will load with a default location immediately. Set slideMap to false if you want to use this. |
| defaultLat | If using defaultLoc, set this to the default location latitude. | |
| defaultLng | If using defaultLoc, set this to the default location longitude | |
| autoGeocode | false | Set to true if you want to use the HTML5 geolocation API (good for mobile devices) |
| maxDistance | false | Set to true if you want to give users an option to limit the distance from their location to the markers. |
| maxDistanceID | maxdistance | The ID of the select element for the maximum distance options. |
| fullMapStart | false | Set to true if you want to immediately show a map of all locations. The map will center and zoom automatically. |
| noForm | false | Set to true if you aren’t able to use form tags (ASP.net WebForms). |
| loading | false | Set to true to display a loading animated gif next to the submit button. Note, that if you don’t have a lot of location data, it may not even be shown because of the quickness. |
| loadingDiv | loading-map | The div that displays the loading animated gif. |
| infowindowTemplatePath | templates/infowindow-description.html | The path to the default infowindow template. |
| listTemplatePath | templates/location-list-description.html | The path to the default list template. |
| KMLinfowindowTemplatePath | templates/kml-infowindow-description.html | The path to the KML infowindow template – used if dataType is set to kml. |
| KMLlistTemplatePath | templates/kml-location-list-description.html | The path to the KML list template – used if dataType is set to kml. |
| callbackBeforeSend | null | Callback |
| callbackComplete | null | Callback |
| callbackSuccess | null | Callback |
| callbackModalOpen | null | Callback |
| callbackModalClose | null | Callback |
Usage:
Assuming you already have your locations.xml file set up in the current directory and the basic HTML copied from the example index file, the following would be the simplest usage example:
1. Include the css file (you’ll most likely want to make modifications to this beforehand):
<link rel="stylesheet" type="text/css" href="css/map.css">
2. Include jQuery if you don’t have it on your page already (the example below uses the Media Temple CDN but you can load it from wherever you’d like):
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
3. Include the latest version of Handlebars.js (this is now required)
<script src="js/handlebars-1.0.rc.1.min.js"></script>
4. Include Google Maps API. If you want to target a particular country add “®ion=” to the end of the URL followed by the country code.
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
Region targeting example:
<script src="http://maps.google.com/maps/api/js?sensor=false®ion=UK"></script>
5. Include the plugin file:
<script src="js/jquery.storelocator.min.js"></script>
6. Apply the storeLocator plugin to the map-container div.
<script>
$(function() {
$('#map-container').storeLocator();
});
</script>
7. Make sure you have the basic form and map container HTML set up or copied from the example file.
Geocoding:
If you want to geocode your locations beforehand like I did, you can use a free service or use the geocode.html that I included. This provides a basic form and will use the Google Maps API to give you the latitude and longitude of the location you input.
JSON (optional):
I’ve added JSON support as an option with version 1.2 of the plugin, which is completely optional. The JSON file included in the GitHub repository is just there as an example. The file was generated via PHP from a MySQL database. The database structure I used for the example is pictured in the following image:

Outputting the JSON from the database is extremely simple with PHP. Make the database connection and use something such as:
$results = mysql_query('SELECT * FROM locations');
$rows = array();
while($r = mysql_fetch_assoc($results)) {
$rows[] = $r;
}
echo json_encode($rows);
Then you’d just set the dataLocation setting in the plugin directly to the PHP file.
Support:
I’ll try to answer basic questions and create more examples but my time is limited.

498 Responses to “jQuery Store Locator Plugin”
Is it possible to have the input form on 1 page and the results & map on another? If so what’s the easiest way to do it? I’m not that great with vars and string etc so not sure how i’d go about achieving this
Hi Dex,
Is there any reason you need to have it display on a new page? It could be done but since we’re using jQuery I’d recommend at least using a modal window to display the results instead of taking the user to a new page.
Hello Bjorn,
I have a great need to display the results on their own page, as it would better stick to the current site layout I am using it in.
Thanks in advance!
I’ve been working on this, and ended up figuring out a fix to push the results to another page. I basicly make my own form on the first page, which is identical to the form used to get the customers zip. I use a php post variable to catch the zip on the next page, which I then echo into the hidden address field. After which I run a jquery timer to autosubmit the zip, giving the affect that the map is being loaded on the 2nd page. If people are interested in this, I’ll post some source.
Thanks!
Hi Christopher,
Can you please post it?
Thanks in advance
On the first page you have the below:
Enter Address or Zip Code:
Which will get a $_POST value of address, and pass it along to locations_map.php
Now on locations_map.php you have the following
The timer/auto-submit
$(‘document’).ready(function() {
setTimeout(function() {
$(“#submit”).trigger(‘click’);
}, 2);
$(‘#submit’).click(function() {
$(‘#user-location’).submit();
});
and the hidden form
<input type="hidden" id="address" name="address" value="”/>
And wala! You have a results posted to another page!
can i see this in action?
Hi there, well done for the nice work, I wonder if this would be possible without the map? I currently have mysql table with locations in UK postcode, all I need to do is have user search their postcode and return the nearest 5 results with a weblink to each result. We never want users to know where or how far the location is?
Any advice much appreciated?
Hi there, please ignore above comment have sorted that bit now. I have tried to use your demo in FF, Chrome & IE, all works fine except IE, it displays the map in right div but not the list of places in left div? I have tried using Edina on your demo site with no success?
Is this not compatible with IE?
Many thanks
Hi Gary, I thought it was working the same in all browsers but I am seeing the same thing that you are. I’ve been meaning to switch the .live() on line 74 to the new .on() http://blog.jquery.com/2011/11/03/jquery-1-7-released/
.live() should still work but it has been deprecated in jQuery 1.7+. I’m not sure if that will fix it at the moment but you could try that until I get time to work on in this weekend.
Hey Gary – oops, I left a couple of console.logs in my last commit (one on line 206 and the other on line 208), which seem to be causing the issues in IE. If you remove those it should be fine. I’ll be committing a new version to GitHub momentarily.
Hi first great script I have been looking for some thing along thse lines….ok simila question to Dex about displaying in another way you mentiona modal window I understand what this is but not the principal about adding this any enlightment on how I can achieve this thanks
Hello SimpleUser, I’m working on adding a modal window option to this plugin. I’m hoping to have it ready tomorrow, or within the next couple of days.
Fantastic news Bjorn
not being the best coder myself I played around with this with some jQuery modal code but I couldnt get it to work once again thanks for this.
I’ve just pushed the latest version to GitHub, which includes the modal window option. I also created a modal window example. Be sure you’re using jQuery v1.7+ or it won’t work.
Tnanks Bjorn this is much appreciated.
Hi Bjorn, that’s great thanks, fixed the ie9 issue.
Kind regards and great work.
Good morning Bjorn, just another quick thing I noticed, if I add a value to the search field to offer information it allows the script to return results based on no search?
In my customised form on search field I have
If the user simply hits enter or search button its returns random results each time. I am working my way to fix this [maybe!] with my very limited knowledge but thought I would share in case you hadnt come across it..
regards
Gary
Ahh wont let me submit my code above input class=”searchfield” type=”text” value=”Enter Postcode…” onfocus=”if (this.value == ‘Enter Postcode…’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘Enter Postcode…’;}” id=”address” name=”address”
Hi Gary, I think I understand what you are saying. I agree that it should stop processing if the input is blank. It will show an alert if the box is blank but it continues to process. I just pushed a new version to GitHub that fixes that. It was basically just missing the else on line 93 – I may have even had it in there at one point and removed it for testing or something.
Thanks again Bjorn, much appreciated, my testing doesn’t appeared to have fixed that issue on my site, perhaps its just mine?
My search field has a text value of “Enter PostCode”, when a user clicks in this is removed and the search begins.. If the user doesn’t click the input field and just hits search it returns values , not sure what they are based on if there is no postcode entered?
Its not a great problem, I can remove the text or reply on my visitors being sensible!!
Kind regards
Gary
Hi again Bjorn, excuse the avalanche of questions!
Are you aware if this could be changed to take the location feed from JSON instead of xml? I only ask because I have a scenario whereby locations need to remove themselves from the search dynamically.
With JSON I would have the location check a box which sets them as ‘unavailable’, this then omits them from any search until they re-check in.
As you probably can tell I am no developer but I dont think I can manage the xml via php/mysql so thought JSON woudl be my only method?
Kind regards
Hi Gary,
You could change it so that it used JSON instead of XML pretty easily. $.ajax can handle both data types: http://api.jquery.com/jQuery.ajax/
You’d then have to change how the variables are collected in the code right below that.
However, you can definitely output XML with PHP.
- PHP4 Example: http://www.tonymarston.co.uk/php-mysql/domxml.html
- PHP5 Example: http://www.tonymarston.co.uk/php-mysql/dom.html
On the clear on focus, try using some jQuery instead. Not sure if this is going to format very well but I use this for accomplishing that (change the ID to your input ID):
if($(‘#inputID’).length)
{
$(‘#inputID’).focus(function() {
if ($(this).val() === ‘Enter PostCode’) {
$(this).val(”);
}
}).blur(function() {
if ($(this).val() === ”) {
$(this).val(‘Enter PostCode’);
}
});
}
hi bhorn thanks for the great plug in. but i have a problem here. whenever i try to search anything it shows all the results instead of showing the nearest one. Can you please help me resolve this issue thanks.
Hi Dipen,
If you want to change the amount of locations returned just use the storeLimit option. If you only want to show 1, then in step 5 above you’d use this instead:
$(function() {
$(‘#map-container’).storeLocator({‘storeLimit’ : 1});
});
Hi, great plug-in – one of the best I’ve seen!
Quick question; is there a way to delay the plug-in from loading until the xml file has been downloaded fully? This would allow us to have more stores listed (we have around 1000 locations)?
Hi Paulo,
I guess you could try using the async setting with the ajax request – adding async:false, after line 120. That may hang up the browser a bit though.
The plugin should be pretty quick by default but I haven’t tried it with that many locations. You may want to try both ways.
Hi again Bjorn, thanks for the responses to my json query. Been trying to fathom this out for ages now with no success due to my lack of understanding, nothing to do with your excellent script. Would I need to change the jquery.storelocator.js file, editing ‘xmlLocation’ : ‘locations.xml’, to ‘xmlLocation’ : ‘locations.json.php’? Then create locations.json.php to pull the rquired fields into it? As long as I call the columns in the table the same as your xml should it work ok?
Sorry for long winded response, using json would really help to remove locations that were offline, I could simply get teh usesr to update their status in php?
Kind regards
Gary
Hello,
I was wondering a few things. Is it possible to not have the map generate after an input, but instead have the map always display with a default location?
Also, how can I set the default map to the terrain setting?
Thanks,
Walt
Silly me. I didn’t realize there was a mapType setting. So, I made the map terrain by default.
But, I’m still wondering the first thing I asked about.
Thanks,
Walt
Hey Bjorn, good the website is working again.
So I basically had the same question Walt has.
Was wondering how to show the map by default and not just after submitting an address.
Tnx allot for this fine piece of code.
Ok, one at a time – I’ll get back to the others later this evening.
@Gary: Yes, you’d want to update the location to path of the PHP file that outputs the JSON. This setting is a URL. Assuming it’s a local file you should be fine using a relative path. You’ll also need to switch the dataType on line 123 from xml to json, line 124 and 129 change xml to json, then just after 129 is what you’ll really need to focus on. I don’t think jQuery’s find is going to work so you’ll need to replace it with something like this (it depends on how the JSON is structured):
$.each(json.location, function() {
var name = this.name;
var lat = this.lat;
var lng = this.lng;
.
.
.
locationset[i] = new Array (distance, name, lat, lng, address, address2, city, state, postal, phone, web, hours1, hours2, hours3);
i++;
});
So, keep the variables the same but change the way they are gathered. Then make sure to create the locationset array at the bottom and include the i++. I didn’t test that syntax but I think it’s right. Once you get the variables set correctly the rest should work without needing any changes. See the following page on the jQuery site for more info on the ajax call with jQuery: http://api.jquery.com/jQuery.ajax/ and the following page on jQuery’s each iterator: http://api.jquery.com/jQuery.each/
Walt and Lau, do you want to still include the input box and allow people to search? If you want to keep that, all you would need to do would be comment out line 43 and run the mapping function with your default latitude and longitude. Maybe I’ll add this as an option to the plugin. For example, put this after line 44:
mapping(44.991565, -93.216323);
Bjorn, I posted a question and then implemented your fix named here and I was able to get the entire view of the US. I would like to have no markers display initially on load until the user enters their data, but have a list of the locations alphabetically… is this possible? Right now it is using the default location named in the mapping lat/long…
Thanks!
Bjorn,
Thanks. Excellent plugin; easy to implement, even for someone without much knowledge of jQuery.
Walt
Hello Bjorn,
To begin: really great plugin, thanks!
I have just one question. Is there a way to tell the plugin to display stores not based on a limit as set in:
$(
Hey John, I think the script is getting cut out to prevent spam. Are you talking about the 26 location limit?
One of the finest map codes i have ever see. Just wanted to say thanks you and nice one.
Yes. I want it to be based on radius instead of a plain 26 location limit. So for example, the sidebar will show all the locations within a 60 mile radius. Thanks, John
hi bjorn,
i’ve used your plugin on my clients website bananwax.com.au however once i input more than 10 stores in the locations.xml file it won’t work…is there something i’ve done wrong or forgetting to change?
i’m not a programmer as such so don’t have any knowledge of jquery or javascript, just basic html/css.
thanks in advance
Hi Dylan,
Did you check to make sure the XML is valid? XML is very touchy – if there is one syntax error it will break. Try running your XML through the validator on the W3C site with your 11th location: http://validator.w3.org/
This is a great script. Thanks for publishing. Question – can it utilize the ability for the browser to detect location? Perhaps by geo-IP address?
hi bjorn,
i thought that could of been the problem, however i inherited the site from another designer who thought it was a good idea to build in tables, so i’m scared to put it through the validator!
i will try though and let you know how i go, hopefully i don’t need to re-build the site from the ground up!
i’ll keep you posted…thanks!
hi bjorn,
i ran the XML through the validator and got this:
Missing “charset” attribute for “text/xml” document.
The HTTP Content-Type header (text/xml) sent by your web browser (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0) did not contain a “charset” parameter, but the Content-Type was one of the XML text/* sub-types.
The relevant specification (RFC 3023) specifies a strong default of “us-ascii” for such documents so we will use this value regardless of any encoding you may have indicated elsewhere.
Warning No DOCTYPE found! Checking XML syntax only.
The DOCTYPE Declaration was not recognized or is missing. This probably means that the Formal Public Identifier contains a spelling error, or that the Declaration is not using correct syntax, or that your XML document is not using a DOCTYPE Declaration.
Validation of the document has been skipped, and a simple check of the well-formedness of the XML syntax has been performed instead.
it still only works if I only input 10 stores. not sure if it matters but i am using australian addresses/locations? any ideas? thanks
Hello everybody, and thank you Bjorn for this EXCELLENT jquery storelocator! I tried to implement a new feature to my project: geolocalize the user in order to automatically display all the nearest stores from him. I succeded to localizate the user, and to return his coordinates (“position.coords.latitude” and “position.coords.longitude”). How can I make them automatically display the map with the markers? Hope it’ll be working soon
Hi Bjorn, Thanks for the awesome plugin and recent upgrade to V3 compatibility. I have been impressed with your JQuery approach since V2 but remain unable to add 2 way marker sidebar listeners. ESA 2009 was able to establish this type of two-way focus link between the sidebar entry and the marker right after Google Maps API V3 was released, and I would like to devise a way to add this to your solution with or without JQuery. If not familiar with the bidirectional binding, please see the Finland example here: http://koti.mbnet.fi/ojalesa/boundsbox/makemarker_sidebar.htm
That sample code has been up since 2009 but there have been few (if any) successful emulating implementions that have been able to duplicate that stellar bidirectional binding functionality between the marker and the corresponding sidebar entry. I also am having trouble porting his elegant javascript functions to your solution.
The Finland approach uses prototypes in the SidebarItem() and makeMarker() functions to establish two-way binding between the sidebar entry and the marker so that when the marker is clicked the sidebar entry is highlighted (and vice versa). When you click the sidebar the map pans and infowindow opens (like with yours), but in that version there is an extra piece, which I crave. When you click a marker, the corresponding sidebar item is also identified (this part does not happen in yours). Can you help me/us figure out how to integrate this excellent Finland (ESA 2009) functionality to your approach? SidebarItem() and makeMarker() are public domain functions but they have been difficult for newbies like me to integrate. Any online or offline advice would be appreciated.
Thanks again for the fine JQuery plugin!
-JO
@Dylan: Can you post your XML data with more than 10 location on http://pastebin.com
@youyouk: Comment out line 43 and run the mapping function with the coordinates – you could put it after line 44. Ex: mapping(44.991565, -93.216323);
@JO: I’ll see if I can get the 2 way listeners working. I’ll probably experiment a bit this weekend.
hi bjorn,
here is the XML – http://pastebin.com/2BiJJ36s
thanks for your help, much appreciated!
Hi Dylan,
It looks like it’s the ampersand in Cnr Marine Parade & Dutton Street. Use:
instead of just &. You can find a full list of special characters and the corresponding codes here: http://www.webmonkey.com/2010/02/special_characters/
Hi Bjorn, good job!
Can i use the plugin without lat and lng??only with city and adress?
thanks
Hi Mike,
There is a geocoding function in this plugin but it currently only geocodes the user’s location. If you know JavaScript, you could make some modifications to use the function starting on line 62. The user location geocoding call begins on line 95. You could copy what’s there down to where the XML data is collected after line 144, format the address, do the geocoding and then use the latitude and longitude it returns for the distance calculation and the locationset array. I chose not to do it this way to keep things quick and to avoid any geocoding errors but I may add it as an option in the future.
Hi Bjorn, just a quick one to say a big thank you for all your help with the plugin and helping get it working perfectly on my site. Really is a great plugin from a great developer.
Kind regards
Gary
HI Bjorn, I posed the bidirectional binding question for mutual event handling on StackOverflow: http://stackoverflow.com/questions/10591816/binding-google-map-markers-to-non-map-sidebar-entries and cited your excellent plug in. @Beetroot-Beetroot came up with a suggestion, and that strategy might be relevant for future enhancements of your jQuery Plugin. Thanks for this excellent tool.
-JO
Hi Bjorn, thank you for such an amazing plugin! Exactly what I was looking for.
I have a small issue. I have kept all the default settings except brought down the store limit to 5. The plugin works great and all my store locations load fine, but when map is initially loaded with results, it’s a bit offset from the first location and the user has to either click on the first result or scroll around to find the location on the map. Any idea what could be causing this? A little issue, but one that my client may complain about.
Hi Romina,
By default the map center’s on the user’s location. If a zip code is entered that can cover a large area. I would try changing the zoomLevel setting out to 11 or 10:
$('#map-container').storeLocator({zoomLevel:11});Works great, thanks!
hi bjorn,
using ‘&’ instead of ‘&’ fixed it! thanks so much! can’t believe I missed that!
all your help was much appreciated!
sorry just one more thing,
when i enter an australian postcode, the map shows somehwere in hungary,
is there a way around this? no big deal but the client would like users to be able to search with postcode as well…
thanks
Can you give me an example of a postal code that causes an error? If you go to Google Maps and put in the zip code does it return the correct location?
Hi Bjorn,
Many thanks for this fantastic plugin !
I experienced the same problem as Dylan with Belgian zipcodes, i simply added an address manual to the xml file, it worked fine when i enter the cityname but not when entering the zipcode.
I solved this by changing, in the index.html file :
to the google domain of the default country (.be in my case)
Greetings
hi bjorn,
when i enter 4220 on google maps it shows me the correct location.
Hi just want to say get plugin but I’m having difficulty changing the markers from letters to just plain markers with the black dot
just wondering if you could give me a example of what to do and i’m sorry but I’m new to jquery so learning as I go along also just wondering if I could use more then one XML file for store lists.
Thanks in advance
Rob
Hello Robert,
If you replace line 242 (map = …) with the following it will use the regular Google Map points.
marker = new google.maps.Marker({ position: point, map: map, draggable: false });I’m not sure if you could use multiple XML files. I’d recommend combining them.
Hi again Bjorn, is it possible within the js file to remove the hyperlink from any information on results to just the web link? For example on your demo http://www.chipotle.com would be a link [pionter cursor] but the info above [Chipotle Edina
6801 York Avenue South
Edina, MN 55435
952-926-6651] wouldn’t be a link to anywhere, currently it moves the map to its pointer but I am using without a map at present?
Thanks
Hi again Gary,
If you look inside the “listClick” function you can replace it with the following:
$('<li />').html("<div class=\"list-label\">" + letter + "<\/div><div class=\"list-details\"><div class=\"list-content\"><div class=\"loc-name\">" + storeName + "<\/div> <div class=\"loc-addr\">" + storeAddress1 + "<\/div> <div class=\"loc-addr2\">" + storeAddress2 + "<\/div> <div class=\"loc-addr3\">" + storeCity + ", " + storeState + " " + storeZip + "<\/div> <div class=\"loc-phone\">" + storePhone + "<\/div> <div class=\"loc-web\"><a href=\"http://" + storeWeb + "\" target=\"_blank\">" + storeWeb + "</a><\/div><\/div><\/div>").appendTo("#" + settings.listDiv);Also, you’ll want to remove the “cursor: pointer;” in the stylesheet – line 91, so it doesn’t look like you can click on the list elements.
Quick question, how do I go about having the driving directions open up in a new window when clicked on. Or, have them open up in a modular window.
Thanks!
I would just like to say a massive thank you for releasing this awesome piece of code for free. The only thing missing here is a “donate” button!
I have now built a bit of PHP which queries my database to build the XML file on the fly. Couple of points for anyone else trying to do this …
1) The XML needs ALL the fields whether you use them or not.
2) If you want to have other inputs within the form that gets submitted for example to exclude/include things from the query which creates the XML then you will need to change this line var userinput = $(‘#’ + settings.formID).serialize(); to something like var userinput = $(‘#address’).serialize(); in the javascript otherwise it will serilaize all the elements in the form and not work.
Thanks again for the excellent code!
Good point on the serialize. I’ll change it to the input ID in the next update.
Excellent work! Thank you for sharing!
I was hoping that you could assist in answering two questions, if possible –
1. How can the distance calculation be displayed in the markers list?
2. How can I easily take an HTML table (outputted from a Salesforce.com database via Siteforce) -> JSON -> Plugin (instead of the XML)
Thank you in advance
Tottaly awsome.
I too would be interested in displaying the distance from, as above.
One other question, can we set the zoom of the displayed map dynamicaly to include the nearest 5 or 10 locations?
So even if the search results are a long way away, and we center to the search location, we still see some markers and the zoom adjusts accordinly?
Cheers,
TW
Distance has has been added to the location list in version 1.2. You’re second request sounds like it could be somewhat challenging – I’m not sure if I want to focus on adding that at the moment over the other potential additions.
Hey Bjorn,
Thanks for this amazing plugin.
One question, is it possible to let the Search field accept letters such as
Hi Jeppe,
It looks like your comment got cut off. You should be able to use any characters that you can with Google Maps.
Hey Bjorn, when I try to use letters like
It seems like my comment gets cut off everytime I use the letters im talking about. But when i use these letters I get the error “Geocode was not successful for the following reason: ZERO_RESULTS”
Can you paste what you’re trying to do at Pastebin?
Hey Bjorn,
Thanks for taking your time to help out, much appreciated.
I wrote my problem over at pastebin at http://pastebin.com/QDE6QyMW
Thanks in advance
Hello Bjorn,
In addition to my previous question; I thought of creating a “view all shops” page where it loads my xml file and list all 55 of the stores in the #list as I listed them in the xml file (i listed them alphabetically).
I want to do this because I have very limited space to work with on the site that I’m working with now, and right now my main shop locator page shows a maximum of 4 shops near the entered location, because I don’t want the horizontal scroll (my store list is horizontal instead of vertical like on your example).
I don’t have that much knowledge of jquery/javascript so I thought maybe you could help me out editing the jquery.storelocator.js to show all of the shops without the need of the form, and save that as another javascript file, and just load that file on allshops.html.
Thanks in advance.
Best regards,
Jeppe
Hello, I’ve a new question: is it possible to make all the marker automatically appears when the map is loading?
Thank you
Hi,
I’m not sure what you mean. Can you clarify the question at all?
Hi!
The idea was to automatically show the stores around a predefined point on the map, before the user make his search.
For example, I succeded to show on the map the position of the user when he’s loading the StoreLocator page, and I would like the plugin automatically show markers around these coordinates.
Actually the plugin only react AFTER the submit of the “formID”. Is there a way to send it the “user-position” on first loading?
(my jQuery skills are as limited than my english, sorry ^^)
Best regards
HTML5 has location detection built in and I’m planning on adding that as an option very soon. However, not all browsers support this. In addition, the user has to agree to let the browser determine their location. It would be great for mobile users.
Hi Bjorn,
Thanks for that great Plugin.
I am trying to implement it to search in Spain, but it does not work. I cannot manage to set up a marker in locations and read it accurately. The list does not include that new marker I write in the xml file, and google maps does not locates it in Spain.
Thanks very much for your help.
OSCAR
Hi Oscar,
Try what Bart mentioned about – replace the maps.google.com in the HTML file with your countries domain extension: maps.google.es
Hi Bjorn,
I solved the above issue.
It was a problem of cache. I firstly checked your xml locations file, so when I try to add or change other locations Firefox cache avoid the plugin to recognise new ones (I guess). At least, that is the way I solved it.
Thanks again for your great code.
OSCAR
Is there a way to include driving directions with this plugin?
To those I haven’t responded to yet. Distance and JSON will be easy and I’m going to include them in the next release (hopefully this weekend). I’ll also try to get the driving directions in but that might take a little longer.
Fantastic news – anxiously awaiting the distance enhancement!
Hi Bjorn, I’m trying to incorporate your plugin into my webpage but I’m having trouble. I’ve copy and pasted your code in and uploaded the xml file just to see if I can get it to work. My page displays everything up to the entry form (where it says Enter Address or ZIP) just fine, but when I actually enter in a ZIP code and hit enter the page refreshes and neither the maps nor the locations show up.
To give you some background, I have at most a basic understanding of HTML and CSS, and I’m currently using Dreamweaver to make my site. I used the built in FTP uploader to upload both the index.html file you provided and the xml file. Any help would be appreciated, thanks in advance
I believe the problem lies with how I uploaded the xml file. Is there a special way I need to do that? I simply uploaded it alongside the html file, is there a particular way it needs to be linked to the file?
Did you upload the JavaScript files? Or is there an example I can see somewhere?
Hi Bjorn, thanks for the quick response. I was able to get the plugin to work myself (the simplest of errors…I fixed it by using the absolute URL when I included the plugin). I actually had another question for you in regards to the XML locations file. I can’t seem to add or remove any locations. I copy and pasted the last location to see if I could add one more, and I even tried deleting all the markers, but the store locator kept showing the original 20 locations. Any help would be appreciated, thanks in advance.
Are you definitely loading your XML file? I’d also try disabling your browser’s cache while you work on it if you know you have the file path correct. The jQuery ajax call will cache the data by default. You can override that with the cache setting: http://api.jquery.com/jQuery.ajax/
If you’re using Firefox, get the web developer toolbar plugin – under the disable menu you can disable the cache. I’m sure there’s probably a way to do it with the Chrome developer tools as well.
I think you have a problem with the jquery.storelocator.min.js file located on your github. I had to view the source of your online demo and copy and paste that file in order to get it working.
For those not getting it to work, download and use this file:
http://bjornblog.com/storelocator/js/jquery.storelocator.min.js
I pushed version 1.2 to GitHub this morning, which includes optional JSON compatibility, a default location option, and the distances to each location in the left location list. I haven’t had a chance to update the documentation above yet but I should be able to get to it tonight.
Alright, the documentation above is updated and there are now examples of setting a default location and using JSON instead of XML. I’m hoping to add some other things soon: driving directions, HTML5 location detection and possibly mustache templates for the infowindows and location list.
I honestly can’t wait for:
- Driving directions
- HTML5 location detection
Bjorn, you are my hero!
Hi,
Totaly understand.
Distance is great.
I had some limited sucsess with Map.”bounds”
Declare it:
var bounds = new google.maps.LatLngBounds();
Then for each marker, extend thebounds object:
bounds.extend(myLatLng);
Then display the bounds:
map.fitBounds(bounds);
But it didnt totaly work.
Worked Ok, unlses the results were out of range, then went haywire.
I was working on displaying a green marker for the location of the search request.
Then having the locations displayed (thank you)
Then using bounds to display the nearest markers, so even if its miles away, the user can still see how far the nearest is.
I may have another go later, if i get some time
Thanks,
Hey,
Nice plugin, just one question. How can I use data from a JSON object received on post (ajax post)?
Is it difficult to make this geolocate and automatically show the nearest store, without entering a post code or address?
OR maybe give the option of “Find me” next to the address input box?
hi bjorn,
great work with the plugin!
i was wondering is there a way to allow users to search using state & postcode?
for example:
i live in Victoria, Australia
i would like to have a form field with the list of states in australia, and second field where they can enter their postcode, the user is then presented with the list of stores in that state and those closest to their postcode.
many thanks in advance
cheerio,
S.
Great plugin, is there a donation button we can send some funds to?
With Default location can we show all stores in the USA?
This would be perfect for our application.
like
http://www.papayaclothing.com/shop/store_locator_v1.php?code=loc&m=
hi bjorn,
with in the XML there is a type – example :type=”Outlet”
can that be incorporated into the search an option or dropdown?
thanks
-alan
Hi,
it is the best store locator ever..
Can You help me? Where I can to change the REGION code?
Becouse if I’m typing a zip code, the map shows a wrong Country.
Thanks
Botor from Hungary
Hi botor,
Change:
to:
Dear Bjorn:)
Thanks but we have an other serious problem:(
In my country have more town that name has ő,
Just pushed v1.3 to Github, which adds direction links and an HTML5 geolocation option. I’ll circle back and get to some of the unanswered questions the next couple of days.
Whenever I try the “HTML5 auto geocode example” from either your demo pages or uploaded to our test server we get the error message: ” Automatic location detection failed. Please fill in your address or zip code. ” – What gives?
…ok, it didn’t work the first 10 times I tried but now – without changing anything – it’s working.
…but another computer in the same office (and on the same wifi network connection) still does not work and gives the error.
I don’t know if I’d recommend using the automatic gelocation on a locator that is going to be used primarily by desktop users. It’s not supported by IE less than 9 and it seems to be faster in some browsers than others. For example, Chrome seems must quicker at this than Firefox. It’s also not always accurate. I can look into it a bit more to see if there are ways to make it better but I’d say that the HTML5 geolocation API functionality is kind of so-so at the moment. I’d definitely recommend it for mobile users over desktop users.
I had the same problem. This may be because after repeated testing attempts, Chrome thinks that the webpage is trying to spam your browser with auto location attempts, so the error appears.
*FIX*
If you click the automatic detection icon in chrome (cross-hair icon on right side next to the bookmark star) you can clear the settings and it should go away.
You can also just disable the error from displaying if you must:
function autoGeocode_error(error)
{
//If automatic detection doesn’t work show an error
//alert(settings.autoGeocodeErrorAlert); /*Comment out this line*/
}
Dear Bjorn:)
Thanks but we have an other serious problem:(
In my country have more town that name has ő
sorry I would like write a comment but the system is not ready….
Dear Bjorn:)
Thanks but we have an other serious problem:(
In my country have more town that name has accented characters..
example the name of town ”Kecskem
sorry I would like write a comment but the system is not ready….
Dear Bjorn:)
Thanks but we have an other serious problem:(
In my country have more town that name has accented characters..
example the name of town ”Kecskeme’t” if i write the name”Kecskeme’t” i get a system message ”Geocode was not successful for the following reason: ZERO_RESULTS”
But if i write ”Kecskemet” (with non unicode character) the script is working correctly.
But in my country the users will write: Kecskeme’t, Pe’cs, Gyo”r, etc…
Can I fix or Can You fix that serious problem?
Big Thanks
Hi Botor,
Try putting the following after line 70. Let me know if it works and I’ll include it as a patch.
Hello,
I’ve had this problem for months now and still can’t figure out how to solve this issue.
I tried your suggestion, but it didn’t solve it either.
I’d love to hear if Botor made it work.
I just pushed v1.3.1 to github, which should fix this issue. Please let me know if it works for you.
Hello Bjorn,
I downloaded v1.3.1 and now I’m getting the error “Geocode was not successful for the following reason: INVALID_REQUEST” when I enter the exact same search text as I did before. I’m searching for the danish city Elsinore (it’s spelled differently in danish, with a special character oe).
Quote from https://developers.google.com/maps/documentation/javascript/geocoding : “google.maps.GeocoderStatus.INVALID_REQUEST generally indicates that the query (address or latLng) is missing.”
Thanks.
Ok, it’s something to do with the character encoding. This is a tough one but I’m working on it. I thought it would be fixed in this version because I was getting umlauts to work but I’m also having it fail with that character.
Ok, I really appreciate your help.
I hope it’s not as difficult as it sounds and I really hope you will make it work
.
Thanks a lot.
PS. I still get errors with umlauts as well, I just tested J
Jeppe, I just pushed v1.3.2 up to GitHub. I removed the extra encoding line I added and all the special characters I try now in addresses seem to work.
Hmm for me it still doesn’t work. It’s not because I’m testing it locally right?
I get the ZERO_RESULTS error again.
Hi,
I have use the store locator and its looking great.
But they really want to display all locations on a map prior to a search.
I guess it wouldnt need to display the list on the left and the pins could be without letters prior to a search.
Is there a simple way to do this.
Any thourghts?
Thanks,
TW
just set you perameters differnt if the input box is empty i.e. first load
if (($(“input#address”).val())!=”" )
{
storenum =19;
}
I also changed the zoom.
//if no text in the text box then set zoom to 11
if (($(“input#address”).val())==”" ) {
var myOptions = {
zoom: settings.zoomLevel,
center: new google.maps.LatLng(orig_lat, orig_lng),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
} else {
var myOptions = {
zoom: 11,
center: new google.maps.LatLng(orig_lat, orig_lng),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
}
Hi Bjorn,
Your script is FANTASTIC – thanks. Is there a way to make the starting Pin image/icon different than the rest? I used a custom marker for my locations and don’t want the same one for the starting location.
Thanks
Hi Bjorn,
tnx 4 ur great job !
i have just a couple of questions …
A. how can i change the distance calculation unit from miles to km ?
B. could i have two different zoom level ? i mean opening the default-location-example.html
the default point at zoom 6 and after the address search query at zoom 12.
tnx
A. solved
How did you change the distance calc from miles to km? I’m also trying to do the same thing.
Hi Luke,
This should be pretty easy. There’s a variable on line 58 called GeoCodeCalc.EarthRadiusInKilometers. You can swap out the Miles one with this one on line 234 and 262. Also, the term miles is used in the output in a couple of places: 281 and 384/385.
I’ll make it a setting in the next version but that should work for now.
I am having a problem that is difficult to explain. It really has nothing to do with your awesome store locator, but more in how it is interacting with other elements on my page. I have a footer element that is usually about 200 px but on the store locator page it is more like 550 px. I have taken away all of the code one at a time it seems that the map-container div is causing an issue. You can see it in action at: http://retailsitecommon.afstores.com/Develop/FreshMarket/locations.html
Any help would be greatly appreciated because this is an awesome store locator and I would love to use it!
Hi Bjorn,
tnx 4 ur great job !
On the basis of your script, I have created a storelocator(http://glenindia.com/storelocator).
Its working perfect , but in some cases(like: state- Haryana & City- Faridabad) it’s doesn’t show any result. XML(http://glenindia.com/storelocator/locations.xml) generated, but result not appears.
Map doesn’t appear in some cases, but xml generated.
Plz advice.
Thanks in advance.
Hi Bj
Ah, a mistake occured! I was saying it was a great ideai to add the Diections features in the last update! Is there any way to add a category filter, with custom markers apllied to them? It could be very usefull
Thank ou for your nice plugin and your support, you rock!
Hello and thank you for all the hard work!
I am currently trying to implement your system, and although I do have it all working correctly
(in modal mode), I would like to push the map and results to another page…Would this be possible with the current codebase?
Thanks in advance for any and all help
I’ll do an example within the next couple of days.
Hi Bjorn,
Do you know how to push the map and results on a seperate page?
For example:
Page A diplays the form with submit button
Page B shows the results including map.
Modal window just isn’t what we need.
Bjorn, this is absolutely AMAZING! Thanks so much! A quick question: Is there an easy way to restrict the results shown by distance? Say you had a drop down box that a user could choose to see the closest locations within a maximum distance of 10 miles, 20 miles, 50 miles 75 miles. Can you then feed that info to the plugin? Thanks again!!!
Or if there was a way to only show locations that were X miles away by default, that would work just as good.
Currently some of the locations are close, but it also shows some that are 5-600 miles away because there aren’t that many in the search location, so it would be good to eliminate the farther ones if it’s possible? Thanks again!
Never mind I figured it out.
I just added a simple if statement around line 234:
//Only show locations that are less than 100 miles away
if(distance<100){
//Create the array
locationset[i] = new Array (distance, name, lat, lng, address, address2, City, State, ZipCode, PhoneNumber, web);
i++;
}
Hi David, this is exactly what I’m trying to implement. Can you give me the exact location that I can past your if statement? I’m in no way a js programmer, but I can follow instructions pretty well, usually
. Thanks for your help.
One more thing… I’m using the xml file instead of json. I’m not sure, but it might change where I put that location limiter statement. Thanks!
changing dataLocation to be a PHP file is not working !!!
also, can I set the dataLocation to URL ?!
Thanks for the great plugin
I was able to get data location to work by setting it to a PHP file. Using the following (in the dealer locator page):
$(function() {
$(‘#map-container’).storeLocator({‘jsonData’: true, ‘dataLocation’: ‘WriteJson2.php’});
});
Where WriteJson2.php was my PHP file and it was in the same folder as the dealer locator page. Try testing your PHP page by itself to ensure it’s outputting correctly, then take the output and run it through a JSON validator.
One last question. I added a checkbox to the form (to show authorized dealers only. Is there an easy way to check if a checkbox on the form was checked and then either A. call a different PHP file that outputs JSON than the default one, by using an if statement in the function call below (e.g. if checked, call JsonAuthorized.php else call: JsonNormal.php).
$(function() {
$(
(oops the system cut if off the rest of the question)
One last question. I added a checkbox to the form (to show authorized dealers only. Is there an easy way to check if a checkbox on the form was checked and then either A. call a different PHP file that outputs JSON than the default one, by using an if statement in the function where the dataLocation is set (e.g. so if checked, dataLocation: JsonAuthorized.php else dataLocation: JsonNormal.php).
Or B. Pass that info to the PHP file that outputs the JSON? The query is working correctly on the Json php file, I just am having trouble passing the variable to the JSON page. I tried setting the form to call itself and then catch the $_POST superglobal, but the JSON php page doesn’t seem to be receiving the variable that was set. Thanks so much for your time!
Yes, you can do A pretty easily with jQuery. If you put something like the following before the $.ajax({ it should work.
if ($('#checkboxID').is(':checked')) { settings.dataLocation = "otherfile.php"; }Hi, this is great, thanks!
Would this be easy to integrate with a wordpress site?
I tried copying the html code into a wordpress page, and copying the folder to the wordpress directory, changing the paths in the index.html…
But it’s just dawning on me that it’s not quite as simple. Anyone know a simple hack?
How familiar with WordPress skinning are you? I’d copy the JS and CSS files into the theme directory and use wp_enqueue_script and wp_enqueue_style in the theme’s functions.php file – that’s the proper way to include these files. You don’t need to include jQuery because WordPress already includes that by default.
So, you’d include the map stylesheet, the Google Maps API script, the plugin script and create a new template file with the Map div and put the code in step 5 in the template file or a separate custom scripts file for your theme.
Dont have much knowledge with JSON but wondering how to approach accessing places/adresses from a saved map within google and feeding this as the locations to this plugin..
It looks as if this is the right direction http://www.bjornblog.com/web/jquery-store-locator-plugin#comment-2327
But not sure where to start. Here is my saved map with all locations. https://maps.google.com/maps/ms?msa=0&msid=212167611152658744851.0004b334c118366207b10
Any step in the right direction would be appreciated, I wan’t to figure this out, just dont know where to start
You can export Google My Maps data to KML, which currently isn’t supported with the plugin but it would make a lot of sense to add it. I’ll add that to the list for the next version.
If you need it fast you could convert the KML data to regular XML without too much work. If you view the source on the “XML format example for location data” link above that’s the format the XML should be in.
Any example template on how to use this in a responsive design layout? Where it automatically adjusts to any screen size whether on desktops, tablets, and mobiles.. I wish to setup the results at bottom for smartphones then when used on tablets the results end up on sidebar..any tips would be helpful..
Hello, ou should try Twitter Bootstrap, it’s a good package to start a new responsive project
http://twitter.github.com/bootstrap/index.html
Hi,Thanks for having this site and for all the hard work. I used the html code part in an .aspx page with data from an .xml file it worked fine(in my local and on a server). Only downside is it takes too long to load the locations, so i’m trying to get .json to work. I’m using visual studio and it’s working fine on my local computer but when i push it to a hosting server it does not work. Please let me know the what might be causing this not to work on the server, and if you have any suggestions for it. Thanks in advance.
Hi, i’m sorry for my english.
I have a problem with the script. In safari everything work perfect but in firefox and in chrome dosn’t work. the problem occurs when I push the submit button and the map doesn’t appear.
I use the version with json data.
I tested the script with firebug but there isn’t errors.
Can you help me?
For more information there isn’t any problem with your on line example but if i try with the same your code downloaded the script doesn’t work and the map did’t show.
Do you have a link where I can see it?
I’m just getting started with your plugin but so far I think it’s exactly what I need. My client will likely be giving me location updates via Excel file, maybe around 200 locations total. Do you know a good way to go from an Excel file to an XML file formatted the way your plugin requires? Or, how difficult would it be to add CSV support?
You should be able to convert from CSV to XML (a quick google search revealed some converters). You could also import the CSV file to a database and output XML or JSON with a back-end programming language – either way.
Another quick question, if I don’t want the Geocoding to be automatic but instead I want to add a “find me” type of button to activate the function what is the correct way to do this? Currently, on a button I’m using:
onClick=” $(‘#map-container’).storeLocator({autoGeocode: true});”
It seems to work but I’m not sure it’s the correct or best way to implement a “use my current location” feature.
Any help would be greatly appreciated.
Thanks.
Yes, the autoGeocode option is the only way to get the user’s location automatically.
Hi Bjorn,
great tool indeed. Although I have question. I would like to use the storecollector in a page with an accordeon jquery. Think “two tabs”, one tab is wholesaler, second tab installers. And for some reason I cannot get both instances at work. I made a second instance of storelocator.js, of the cms, renamed all divs, made a second xml, but now way that the both work (seperate instances work fine, even with the changes). I’m not a programmer, but can read/understand code quite well. I think it’s a js or geocode conflict (something that cannot be loaded twice). I searched some jquery forums, but no result.
,
So, any advice on putting two instances on the same page
best regards
gys
Hello, I dont know why, but I can apply a new PinColor to the markers of the “listclick” (for example a green one when the contact is a client, and a blue one when it’s a prospect).
Unfortunately,I tried to apply it to the markers shown on the map, but in this case the colors are shift. The first got an “undefined” PinColor, and the second marker got the color of the first one, the third one the color of the second etc etc …
Here is my code :
_________________________________
var $storeType;
if (storeType == “CLIENT”) {
pinCouleur = ‘A5B478′;
}
else {
pinCouleur = ’3A87BD’;
}
var pinImage = new google.maps.MarkerImage(”http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=” + letter + ”|” + pinCouleur + ”|” + settings.pinTextColor,
__________________________________
…
I made a screenshot, it will be easier to understand ^^
http://www.hostingpics.net/viewer.php?id=697953storeLocatorPinColor.jpg
http:// http://www.hostingpics.net/viewer.php?id=697953storeLocatorPinColor.jpg
Help would be appreciated
how do u fix it ?
Hi, I like this plug in… could you just tell me if there is a way of showing the location that you just search on the map with a different colour pointer so when I type a post code I want that to be a green pointer on the map where as all the stores/my locations are red pointers. If thats possible how do I go on about doing it?
Hello, check out here:
http://www.bjornblog.com/web/jquery-store-locator-plugin#comment-3253
I’ve tried integrating this into a wordpress theme as well and cant seem to get the map to display. What is odd is that if I have a standard HTML file serv this page, the map works beautifully… Once I put it in my theme .php file the map wont display.
I’ve done some debugging and can see that the scripts are registering and appear to be working, but when I enter a zip code and submit, this registers in the :
But then nothing comes back from the maps API… Its like it sends the request, but never gets anything back.
Looks like my code snippets didnt go through…
I
Hey I love the plugin. But I’m having problems in Chrome especially. I have the plugin on a a jquery mobile page and when I enter a postal code and press submit, the map appears on the page for a minute then disappears.
https://staging.nvenergy.com/jq/locationsCopy.html
Hello, you should try to declare the storelocator javascript in the footer, AFTER the Google map script.
I’ve been trying to get this locator to work with roughly 80 locations. My problem is, it will work with 26 locations, however, as soon as I add more than this, it stops working. How can I fix this??
Is there possible to have an select list with geotags thats loads on map just like search?
I’m showing only the 5 closest stores and have been able to add a button to show 10 or 20 stores but is it possible to add a button to “show next 5 stores” and have it replace the currently displayed stores with the next 5 in the array? If so, what code would I use?
Anybody have a solution for this?
Hey Bjorn thanks for the hard work for the script, i have been having trouble trying to implement it with my coldfusion server side would love if you could take a quick look and let me know if you find anything that could get it to work for me! http://www.cheapcarpetmelbourne.com.au/index.cfm/5/storelocations
Cheers!
It doesn’t look like it’s there anymore. If you have a test page I’ll take a look but I have no experience with Coldfusion.
Hi there again,
Thanks for all the hard work on this excellent piece of code … was wondering if anyone has a way of easily adding a pin for the entered search location – preferably with a different coloured pin.
Useful when you start to scroll the map around.
Hello it’s pretty simple:
Check out my code and the line I’ve added, you’ll notice you have to declare the var “image” with the link to the icon:
//Ferme si la touche Echap est appuy
//Ferme si la touche Echap est appuyee
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$(‘#overlay’).hide();
}
});
}
var map = new google.maps.Map(document.getElementById(settings.mapDiv), myOptions);
var image = ‘/css/img/marker.png’; // <—– CHANGE THE ICON PATH HERE!
var marker = new google.maps.Marker({
map: map,
icon: image, // <– DON'T FORGET TO ADD THE "icon: image," HERE
title: '',
animation: google.maps.Animation.DROP,
position: map.getCenter()
});
var markers = new Array();
//Creation de la bulle infowindow
var infowindow = new google.maps.InfoWindow();
Thanks very much … I will give this a go later.
Worked a treat – thanks for the help youyouk.
Useful stuff on googlemaps pins here: https://developers.google.com/chart/image/docs/gallery/dynamic_icons
Thanks youyouk, I haven’t had time to keep up with these questions lately.
Hi, where on the code it needs to be inserted?
Is it possible to have this so people can enter Australian Post codes, and not USA Zip codes?
Thanks for a great script.
You should be able to get this to work by changing the call to google maps to your country’s extension.
In the example files you’d replace:
http://maps.google.com/maps/api/js?sensor=false
with:
http://maps.google.com.au/maps/api/js?sensor=false
where should I put this to make the button find me work? Sorry.. I’m newbie.
onClick=
$(
Hi Alan,
Can you post what you’re trying to do on pastebin.com? Comment code from visitors is going to be stripped out.
If you want to just turn on the autogeocoding use (have it run automatically if it’s a compatible browser):
$('#map-container').storeLocator({autoGeocode: true});If you want to create a click to locate button you could replace the if statement on line 123 with something like this:
$(document).on('click', '#buttonID', function(e){ e.preventDefault(); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(autoGeocode_query, autoGeocode_error); } });I want to edit infowindow style. I tried the options but not worked. any other way?
Yes, you can edit the stylesheet to make it look however you want it to. The css for the modal window begins on line 145 in the css/map.css file.
Hello Bjorn,
I think modal windows is different than Infowindow ?
Like jaydev,
I want to edit infowindow style with background color and border radius.
Any Idea?
Oh, yes I misread that. I don’t think you can just change the style of the infowindows very easily. I’d look into the InfoBubble library on this page: https://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries
Hello Bjorn, see the script is still doing very well and continues to help people out. I am looking to slightly change my implementation of the json script you kindly helped with.
Is it possible for me to change the ID names of ‘form id=”user-location”‘, ‘input id=”address”‘ & ‘input id=”submit”‘. I have changed form id to my own name in jquery.storelocator.js but cannot work out which fields to change for the latter 2, there are multiple entries in the js file for ‘address’ & ‘submit’.
Kind regards
Gary
Hi Bjorn, please ignore my post above, found out now where I was going wrong..
Thanks
I am having a problem that I am not able to scroll through my locations list (#loc-list) when I am on an Android phone. It works perfectly on my iPad on on any desktop, but when I am on my android phone, it doesn’t scroll. I can, however, scroll around the map with no problem, so there has to be a setting somewhere that I am not seeing that allows the scroll function to work.
Any ideas?
Hello Bjorn, I only display 2 results from my searchs, if I required the results to display horizontal rather than vertical would it be possible using the current css file?
Thanks
Oh yes.
It took me quite a bit of work to change it around.
http://jsfiddle.net/stillb4llin/CnHkP/
Will probably want to change your height to the right number… also, depending on the number of items depends on the % for width of the list.
I have this set up more for a mobile app….
Hope this gets you a start in the right direction.
Hello Bjorn! I must first say this is quite an awesome piece of work; it really works great and I’m having a lot of fun with it. I am *VERY* new to jQuery and have been asked to put a store locator into my company’s mobile website and this has brought me light years closer to what they are looking for.
I’m trying to do something a little different; I wanted to make the list of nearby stores be a collapsible set; and although my code seems to be spitting out OK (if you grab it via a debugger and paste it into a static page it renders perfectly), because it is generated dynamically it’s not showing up as collapsible. From the things I’ve read, the DOM needs to be refreshed for it to show up as that sort of element. I’ve now reverted back to the original code (as they’d rather see it working than pretty, you know how it is
and wanted to try something simpler, so for the “loc-directions” div I tried to change the distLink to a “data-role=’button’”. Even this simple mod won’t show up as a link button, I’m guessing because of the reason stated above. Is there a simple line of code I can add to make this display correctly? Someone suggested “$(‘#element’).page();” but this doesn’t seem to work. Any help would be much appreciated.
And BTW, *Thank You* for such a wonderful script. It is really something else!
-Felix
If you provide an example from jsfiddle of your code and such, maybe I can look at it.
Hi Bjorn,
thats for the awesome script. Do you have any idea how i can parse the data (xml) via a string variable to your Java script function? I need to avoid to create a data file which someone could download.
Any advise is greatly appreciated.
Cheers,
Eric
PS: for someone interested in adding a little “waiting spinner” to it, add this to your code:
Inside the submit button div:
Add these line to the javascript file (jquery.storelocator.js) after row 198:
document.getElementById(‘sl_map_spinner’).style.display = ‘inline’;
and this after row 429:
document.getElementById(‘sl_map_spinner’).style.display = ‘none’;
Spinner gifs can be found through google, like this one:
http://www.markit.com/assets/images/spinner.gif
Do you have access to a database? I’d go with the JSON method if you don’t want a locations file to exist on the server.
Thank you Bjorn for the excellent plugin. I have what I think is an easy question.
When the page loads and no details for search have yet been entered, how can I display a zoomed out map of the US with the first 26 locations listed alphabetically? Or, just a map of the US so there is no empty space where the map container is?
http://www.travelpro.com/whereToBuy.cfm
Thank you!
Is there a way to show only the locations that are let’s say only 10 miles away? And if there are no it would just give an alert that no locations near? Thanks!
start here: jquery.storelocator.js file
var settings = $.extend( {
‘mapDiv’ : ‘map’,
‘listDiv’ : ‘list’,
‘formID’ : ‘user-location’,
‘inputID’ : ‘address’,
‘zoomLevel’ : 26,
‘pinColor’ : ‘fe7569′,
‘pinTextColor’ : ’000000′,
‘storeLimit’ : 10,
‘distanceAlert’ : 60,
distanceAlert to 10
should work for you
Hi Nick,
I’ve added a new maximum distance option to the latest version of the plugin. To see how it works check out he maximum distance example link above.
This tool has made my life easier but I keep running into a problem…if I rename the XML file and change the name in the js file, it the tool no longer reads the file. This also happens when I open the XML, edit the contents and re-save. Any ideas? Does the XML need to be a specific encoding?
Thanks.
You want the character encoding to be UTF-8.
Hello Bjorn!
Compliments for your plugin, but for me is slightly compless!
I use Wysisyg WB with your plugin and in theory for this, not have to change never, only write the shops in but not are all function mentioned on your site, or not work correctly because if it’s setting in “Store Locations” and the standard setting for DistanceAlert is 60 Miles. Not are more options you have writer on your site and if i modify one of pages published, then i insert others clients/shops in “store locator”, replace automatically all.
Now, if i want setting plus of 26 clients shops (i’ve up to 500), what is the istructions to modify it from Wysiwyg? Or parameter to change from A to Z and change from 1 to 500..?
And if want change the parameters of research from ZIP (in Italy is CAP) and region and city, separately? Is possible by Wysiwyg? The principal problem at moment is only the setting of “Store Locator Form ID” and “Store Locator Map ID”. If you have time and possibility, help me please..!
This is the interested site: http://www.switch-it-starter.com/negozi.php
Thanks.
Regards from Italy.
Andrea.
Hello Bjorn. You have visualized my request? Is a reply fot my problem?
Thanks
What is the reason to have zip and address in different boxes? One box that does it all is better. Less for user to mess up.
If you want to modify the the store limit look for
‘storeLimit’ : 26,
in the jquery.storelocator.js file. you aren’t going to be able to WYSIWYG with this file. open it up with a text editor. You will have to modify that field.
you will also need to modify
for (var y = 0; y <= storenum; y++)
{
var letter = String.fromCharCode("A".charCodeAt(0) + y);
change that from A…. to a number
You will also have to adjust your marker CSS.. should be able to do that in your WYSIWYG editor.
Good luck
I tried this but nothing seemed to change. It’s still showing letters and capping out at 26 even though i sent the store limit to 80
I just pushed a new version to Github that removes this limitation, among other things. I don’t have time tonight to update the documentation on this page but use those files instead. I’ll update this page tomorrow.
There is a way to change the red markers with a custom marker, let
Hi Cristiano! In the jquery.storelocator.js you’ll find this part:
++++ Original Code ++++
//Custom marker function – alphabetical
function createMarker(point, name, address, letter) {
//Set up pin icon with the Google Charts API for all of our markers
var pinImage = new google.maps.MarkerImage(“http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=” + letter + “|” + settings.pinColor + “|” + settings.pinTextColor,
new google.maps.Size(21, 34),
new google.maps.Point(0,0),
new google.maps.Point(10, 34));
var pinShadow = new google.maps.MarkerImage(“http://chart.apis.google.com/chart?chst=d_map_pin_shadow”,
new google.maps.Size(40, 37),
new google.maps.Point(0, 0),
new google.maps.Point(12, 35));
++++ Replace that with the following code ++++
//Custom marker function – alphabetical
function createMarker(point, name, address, letter) {
//Set up pin icon with the Google Charts API for all of our markers
var pinImage =new google.maps.MarkerImage(‘path/to/marker-image.png’, null, null,
new google.maps.Point(14, 13)); // don’t forget to replace the path!
var pinShadow = new google.maps.MarkerImage(‘path/to/shadow-image.png’, null, null,
new google.maps.Point(14, 13)); // don’t forget to replace the path!
By the way I want to say THANK YOU BJORN for this amazing script!
Good luck Cristiano,
Tim
Hi, I am trying to link this in with Joomla – Has anyone done this before.
When i run the html file from your plugin on my server everything is fine, when i try add the code into joomla I get a blank page.
Any help would be appreciated.
Great Plugin and it is what I have been looking for
Thanks
Do you have a link to the page? Are you sure jQuery is being included?
i used on joomla article and it works fine
try using an to load the page that works into Joomla… That’s how I’ve worked around any issues with joomla.
http://www.w3schools.com/tags/tag_iframe.asp
It is probably because you need to change your infowindowTemplatePath and listTemplatePath. I had the same problem in Drupal and this fixed it
ciao,
about the zip code you must use maps.google.it instead of maps.google.com
and about the 26 stores, the plug in shows the closest 26 shops to your location
i have 220 stores in mine and if u change the zip code it shows to u the nearest.
about miles u have to change the distances in km. if u check all the discussion
u’ll find all the answers to your questions as i did for
http://www.fan3rush.com/sdt/index.php?option=com_content&view=article&id=82
hi,
tnx for the great work …
i would update my webpage with checkboxes using the “type” key in the xml
something like in the following link:
http://storelocator.googlecode.com/git/examples/panel.html
have u any advices ?
tnx
marco
ps btw to work on joomla i used the iframe tag
Did you use the xml file and use the type field and then link that to the checkboxes to only display the type that was checkmarked?
Hello Bjorn,
Congrats for a very nice tool. Great work with this store locator plugin, it’s just what I’ve been looking for my current project.
I have also a question. How to insert, let’s say an icon that describe the type of store into the infowindow (i’m thinking at something like: img src=someimage.png. I have been playing around but it seems I can not get this to work. To say that my javascript/jquery knowledge is somewhat limited(i know, i am struggling with this).
Thanks,
Daniel
Where do you want this to show up at? what part of the display? An icon..what size?
Hello Nicholas, and thanks for replying.
I’m interested in showing an icon to reflect the type of marker in the infowindow. Currently I have in my xml file three types of locations that are being displayed into the infowindows in text format.
What I am trying to achieve is to place an icon before the text into the infowindows just for visual styling.
E.g. I have my infowindows structured like this:
…………………………………………
Address:
City:
Hours:
Phone:
Fax:
Text that describes marker type:
…………………………………………
What I am trying to achieve is
E.g.
Address:
City:
(small clock icon)Hours:
(small phone icon)Phone:
Fax:
(small location type icon)Text that describes marker type:
I hope you can understand what I’m trying to do here. I’m sure it exists a better way to do this.
Thank you,
Daniel
Hi Daniel,
I’m going to be releasing a new version within the next couple of days that will allow you to do this very easily. There are a lot of other updates and improvements so if you can wait until then it will be worth it.
cool stuff!
Hi there once more, is it possible to have the script search only uk locations? I have a store in Birmingham UK, when the user search for ‘Birmingham’ it shows Birmingham US instead of UK?
Thanks
u have to use maps.google.co.uk instead of maps.google.com
I used this which seems to work geocoder.geocode( {‘address’:request.term + ‘, UK’}
Cheers
LINK! How can anyone try to guess at your problem if you don’t provide a link!?
Hi Bjorn,
Thanks for this great script. Everything is working fine but I do not know how to show a marker for the initial location. The map is showing the exact location from the start perfectly, but I need a marker to show it more recognizable.
Can you tell me what code to implement and where to put it.
I have been trying
var marker=new google.maps.Marker({position:latlon,map:map,title:”You are here!”});
on several positions in the script but I can not get it to work
Thanks,
Arnout
Hi Arnout,
I’ve added a new originMarker option to the new version of the plugin, which is now available.
Hi, congratulations for this great plugin
I wanted to know how can I customize the information window that is showed when you click on a marker.
With the current version you’d edit the code in the create_infowindows function – line 455. However, I’m working on a large update that integrates Handlebars.js for much easier template updates. I’m hoping to release it within a day or two.
will u integrate selections on type field or something else operative ?
or it’s just an update on the template ?
anyway
tnx
Great
Here is a test page for the locator i’m trying to build:
http://belove.mybigcommerce.com/store-locator/
having trouble getting the modal window to fire. I’m using bigcommerce as the ecommerce backend for this, and when i click submit, i see a “loading” option at the top, which i know is part of bigcommerce. Is this code conflicting the reason why it won’t pop up? Any help would greatly be appreciated.
It can’t find your locations data file. If you check the console in Chrome developer tools or Firebug it will show any javascript errors. It’s looking here: http://belove.mybigcommerce.com/store-locator/locations.xml
Also, I should be able to release a new version of this plugin today, which has many updates and improvements.
great – i’ll try to redirect it. would that kill the modal window though?
BOOM! Worked great – this script is fantastic!
checking out the new version, are they not supposed to work offline? i’m not getting any activity with the source files.
Oh, the new jQuery reference probably doesn’t work from your local machine. If you have web server installed on your computer try that, otherwise upload it to a test directory on your server. Also, make sure you’re including Handlebars and the new template files. Handlebars is a new requirement for the plugin.
it’s all good – i’ve got it running and it’s 99% perfect. The updates are incredible – way to go!
I just have one small bug that i’m trying to figure out now, it seems that it kills my jqzoom on my page: http://belove.mybigcommerce.com/an-eagle-and-a-prayer/
any thoughts on why it would be doing that?
thanks again for your help!!!! Do you have a donation page?
I don’t see any errors but I noticed that you’re including jQuery twice – version 1.6.4 and 1.8.3. You’ll want at least version 1.7 for my plugin to work. I’d try just including it once first to see if that fixes it.
Hi please tell me theres a way to save stores, when a user hit button save it only show on page 2. Like favorites stores. And is there a way to have more then 1 picture at as flags? i have searched and searched but no luck so far.
I’m not sure what you mean by save stores. What would be saved and what would it save to? This is only a front-end plugin. If you mean save the user’s location preference, I think that would need to be handled by the developer integrating it into the site because it would likely be different for each case. You could easily add a “save” link to either template with the location ID but what you do with that is really up in the air and it goes beyond the scope of this plugin.
Unique marker images for each location isn’t currently supported but you could definitely add unique images to the templates (infowindow and list).
Hi again thx for your reply, im sry but my english is not the best. Lets save i have 4 stores thats displays on index.html and user clicks on a save button for store 3 and then goes to page favorites.html and it only shows store 3. Thx for help
About my other question so i have changed my icon pin marker from red with letter to an image and that works fine, but now i want to have 5 images to select about deppending on value from json like “+ storeIcon +” 1,2,3,4 or 5.
Are u from sweden?
/ ImSoHappy
Hi,
We want to use your store locator script, but we want to use wordpress with it…
We have a custom post type dealer and we are using Json api for wordpress to output our post type in json format. But it’s not a .json file
Its something like that : http://mywebsite.com/?json=get_recent_posts&post_type=detaillants&custom_fields=wpcf-locname,wpcf-lat,wpcf-lng
Can we use this URL in the datalocation or is there a way for doing this?
Thanks
Yes, definitely. Just use the full URL that outputs the JSON for the dataLocation option. It most cases the location of the JSON data will be a URL. I just used a file because I didn’t want to give the impression that any back-end work was required for this plugin to work.
Ok…
So if my variable are different that yours… locname = wpcf-locname does i need to change someting somewhere? jquery-store-locator.js
Yes, see lines 336-349. So, for name it looks like you’d want:
I got this error :
ReferenceError: locname is not defined
var name = this.wpcf-locname;
I got this for my field in my json file
..,”custom_fields”:{“wpcf-locname”:["Oktane Design"],”wpcf-lat”:["45.882144"],”wpcf-lng”:["-72.486421"]}}]}
Try:
TypeError: this.custom_fields is undefined
[Stopper sur une erreur]
var name = this.custom_fields.wpcf-locname;
I need to see an example of the full JSON structure in order to be helpful. If you can, post the data on pastebin or reply with a URL.
Hi Bjorn !, Nice Job!, It has been very helpful for me. I have a question, if you can help me, I need that I may appear markers as a filter on the list, as a category of markers, but I am not able to do so because I find no way to change it in your code, you may be able to help me, I appreciate it, thank you very much.. This link is to a site that I want to see if I can do the same http://www.guiamap.com/mapa.php?city=1
Ernesto
Great tool, love it!
I’m having problems with the xml file path. I need to put the xml file a directory up, so something like this: ‘dataLocation’: ‘../Maps/locations.xml’, or even: ‘dataLocation’: ‘http://domainName.com/Maps/locations.xml’ , but neither of those paths work(locally and on the server). It works fine locally when I use: ‘dataLocation’: ‘locations.xml’ .. but the way our CMS system is setup I can’t upload the xml to the same directory.
Any ideas?
Thanks!
Maybe try using the full path to the file. If you’re on Linux, something like /home/www/… If you’re using PHP you can use the getcwd() function to find it.
no luck
Still trying to figure this out. – not using php. Any other suggestions?
Thanks!
Have you tried just a relative path yet from the web root? Like: ‘/Maps/locations.xml’
yes, that is not working either.
I did a test, putting the XML file one step up, and this worked for me:
$('#map-container').storeLocator({'dataLocation': '../locations.xml'});Are you on a Apache or IIS server? Also, what CMS?
Hello,
this is amazing and worked great. Suddently 4 days ago it is not work anymore. Did something changed i.e. google api which could effect the map is no longer displayed?
Many thanks
Not that I’m aware of. All the demo examples above are still working. Did anything else on your site change? Or did you upgrade the plugin to the latest version? There are new requirements (Handlebars.js) for the latest version of this plugin and a couple of the option names have changed.
works perfect again!
(there was an xml loading issue with a new database entry)
Hello, i try you’re plugin in IE7 and he doesn’t work, it’s normal ?!
but i love it thx for this
oh, unfortunately, i disabled the js on IE7.. x) sorry
other question, it’s possible to run this script from jquery 1.4.2?
You need at least 1.7 for this to work.
yes i know, but my website turn with jquery 1.4.2 i cant use you’re script,
there is nothing to make possible to make it work in 1.4.2?
Can’t you update to a newer version? 1.4.2 is almost 3 years old.
If you want to change the code I think it should work if you change the instances of .on() back to .click() and .submit(). I’d really just recommend updating jQuery though.
i know.. in my personnal website i use 1.8.3 but for my works, he uses 1.4.2…. -_-
i try you’re suggestion thx
he doesn’t work
Hi Bjorn,
This is a great update and a great plugin, thanks! I only was wondering why you have on line 224
var userinput = $(‘#’ + settings.formContainerDiv + ‘ #’ + settings.inputID).val();
when the inputid is unique? because an id is always unique.
so you can also make it like this:
var userinput = $(‘#’ + settings.inputID).val();
best regards,
JP
I don’t remember at the moment if there was a specific reason – I was probably just thinking better targeting. I write a lot of CSS so I’m used to making selectors granular. I will check out performance comparisons to see if it makes any difference.
I also changed the keyup on line 271 to $(document).keypress(function (e) {
because when you have keyup, it still postsback. As Kenneth comments on this question http://stackoverflow.com/questions/1563062/prevent-form-submission-with-enter-key
I’m using preventDefault() in the get_form_values function, which should stop any default submission.
Hi Bjorn,
Great plugin been using it everywhere I can. Just wondering in the UK we have postcodes like SW1, and when we search for them the map will goto a place in Germany. Just wondering if there away to stop that and have it only goto places in the UK? I’ve tried using maps.google.co.uk but no luck.
Would be great if you could point out my idiocy or maybe have another method to fix it
Thanks
Mc
Can you try replacing line 121 with the following in jquery.storelocator.js and letting me know if it works for you?
geocoder = new google.maps.Geocoder().setRegion('uk');Nevermind on that last post. They use the following example in the API examples:
http://maps.google.com/maps/api/js?sensor=false®ion=UK
hello,
what is a maximum store locator that i put in .xml ?
I have 8000 stores… it’s ok for the plugin ?
There really isn’t a limit but I’m not sure at what point the performance would start to degrade. I haven’t had a chance to try it with that many locations. If you are able to test it let me know how it performs.
if you want try with many location i have .xml but you need to edit some field
http://www.artsx.fr/storelocator.xml
I think i have one error somewhere in one of the lines because he doesn’t work when i try after edit field.
You can test if you want, i puts on tonight !
I edited the file
I added the files to the plugin works, I’ve tried with one, I put the minimum information required for the plugin to work.
I do not know if I forgot something or if I make a mistake somewhere ..
oh yeah, it’s working !
but i have error when i put on input the adress.
he makes me “ZERO_RESULT”
i’ve add button for geolocalize me on the jquery.Store.locator.js (i see on prev comment the code for add this but i think i dont add this correctly
if you want check this : http://www.artsx.fr/storelocator/
it works !
lol
i forget to change containerdiv ID…
hi – you’ve done great work (best of the free store locators I’ve seen), and I have just 1 question:
Using the Maximum Distance example, when doing a search is it possible to first clear any *existing* results from the location list panel before showing the new results? This is because if you run multiple searches of different locations (different states, just for example) the results of the different searches are merged together even though they could be in vastly different locations much further than the specified distance.
Thanks so much for any help!
Vincent
The data should reset when you submit the form again. Is it not working that way?
no, it will add it to previous searches run in the same session, for example if I’m check multiple postcodes in one visit and it only finds one or two results it will merge it with previous results based on distance.
Alright, that’s a bug then. I’ll work on fixing it. My intention was to have it reset on every search.
Thanks Bjorn – I really appreciate it
Vincent
A fix will be in the next version, which should be up this weekend. If you need it sooner you can add the following after line 288:
Thanks so much Bjorn – I’ll test that as soon as possible!
Vincent
New version of script works perfectly with max distance and clearing old results before listing new finds – thanks so much! Great work.
Vincent
Hi,
I was wondering if it is possible to still show the default map onload (or fullMapStart) and use the maxdistance feature. If I turn the maxdistance feature to true and the fullMapStart to true, I get an alert stating “Unfortunately, our closest location is more than undefined miles away.” But if I exit that alert and enter an address and select a mileage distance – it works as expected.
Any help would be awesome. Great script!
I’m trying to think of a way to do this but I’m having difficulty. By having both set, the script basically needs to ignore the maxDistance setting the first time the page loads but then ignore the fullMapStart setting when the form is actually submitted. I don’t want to require cookies. I’m not sure yet if I’m going to be able to get this to work.
This should be working now in the latest version that I pushed to Github last night (1.4.2).
Hello,
it’s possible to add a loading while the map loads to understand that the script is in the process of turning it to wait?
It’s pretty easy to do with jQuery. I’m adding an option in the next version, which I think should be released tonight or tomorrow.
I’ve added a loading option in the latest version, which is now on Github.
One fast question. I need to know if you can point me in the right direction on the using of a start pin. I see the ‘origion marker’ option, and have set it to true, but nothing happens, and so I just needed to know what I needed to be looking for to fix the issue.
Thanks
Are you using any other options?
Bjorn,
Thanks for this great plug-in, works beautifully.
Quick question, I tried using the show origin marker… but it doesn’t show….
Are you using any other options? It should just show a blue marker in the center.
Now works.
Awesome plug-in, although I can’t seem to get it to work with over 114 entries. Any suggestions?
Using XML? Someone above has it working with 8,000 locations and I’ve tried that data myself and it works. I’d guess that you have invalid characters in the 115th location. You can also use the W3C for validation on the data: http://validator.w3.org/
I’m trying to use your plugin right “out of the box” locally, and I can’t get it to work. When I search the map pulls up but the panel area does not. And it’s only showing 1 marker in all of MN, with not info box.
Does it only work on the server and not locally?
Thanks!
Change the jQuery call if you want to run it locally:
http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js
I did that(sorry should have mentioned that), looks like the jQuery is working correctly. I just looked at the Firefox FireBug console, I’m getting this error: “not well-formed {{#location}}”
Hmm… yeah, I’d recommend running it on an actual web server – it doesn’t seem to run just from a directory on a local machine. XAMPP, AMMPS, WAMP, etc. if you want to set up an easy local web server. I can look into seeing why it doesn’t just run from a directory, it looks like it’s something to do with the template files.
Just uploaded it to a test server, works on the server perfectly. It would be nice if I could test locally for some future projects, but definitely not a deal breaker!
Thanks!
I probably should add that the jQuery link is the ONLY thing I changed. everything else is as it was on download. I’ve tried several of the example pages and it’s the same error.
Why won’t the json example accept any special characters?
I’ve changed the “” tag in json-example.html to “” and if I type with special characters in the it shows them correctly, but the data from the “locations.json” file won’t show special characters. They are replaced with “�”.
I’ve also tried adding “contentType: “application/json; charset=utf-8″” after line 302 in the jquery.storelocator.js file.
Do you know what is wrong?
Thanks
edit: I’ve changed the meta tag in json-example.html to meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″
The meta tag is currently in HTML5 form. Have you tried seeing if the JSON data validates? http://jsonlint.com/
Yes it is valid JSON. In fact all I did was editing one of your shops name in locations.json from “Chipotle Minneapolis” to “Chipotle Minneapolis” (with special characters instead) and the result was: Ch�p�tl� Minneapolis.
I’ve tested this on localhost and in firefox, chrome and internet explorer.
I tried copying in some special characters into the JSON file on my local setup and couldn’t reproduce your issue. Can you possibly try on another server? Also, what program are you using to edit the files?
I am programming in NetBeans IDE 7.2.1, i don’t know if it has something to do with this program or if I made a mistake myself, but after trying this in Dreamweaver it worked without any errors/problems.
Hello,
You think it’s possible to add two loc_list at the same time?
one for the research you put and secondary with city around ?
I’m not sure I understand what you mean. You could have two location lists if you wanted. Line 721 in version 1.4.2 is where I’m appending the list html.
Hello,
I love the plugin! Just one question how does it calculate the distance between the input and closest location?
In my example it shows me from zip 07755 to 11206 (which is one of the locations) as 30.16 miles, but when I hit the directions button and it takes me to google it gives me 3 suggested routes which range from 58.2 miles to 62.7
The issue I have with this is that there is a closer location to this (I am only showing 1 location at a time as per clients wishes) which is 42 miles… yet it shows this one because according to whatever the calculation is its only 30.16 miles.
Any advise or help?
If you check the “A note on the distance calculation” above that details the current distance measurement. I’ll most likely add an option for the Distance Matrix API in the future but I’m not sure when at this point.
Hi Bjorn, have you done any versions of this where the form autocompletes?
I haven’t done anything like that yet.
I’m working on that part now
How about anything where locations have “features” checkboxes? IE- Drivethrough, Dine in, Accepts cc’s, etc?
Nope, haven’t done anything like that yet either.
Hi
Love the script, I just want to acheive one thing that I can’t work out. Using the XML file and the type attribute, I want to display different coloured marker for the different types in the xml file. There will only be 2 different types. I can’t work out how to do it.
Is it possible to set the type attribute to a global variable that I could then use in the following function to change the pincolour? A previous commentor was doing it this way, but I could not understand how they applied th Type attribute from the xml file to use as the if/else key.
Any help would be most appreciated.
James
//Custom marker function – alphabetical
function createMarker(point, name, address, letter) {
//Set up pin icon with the Google Charts API for all of our markers
var pinImage = new google.maps.MarkerImage(“http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=” + letter + “|” + settings.pinColor + “|” + settings.pinTextColor,
new google.maps.Size(21, 34),
new google.maps.Point(0,0),
new google.maps.Point(10, 34));
var pinShadow = new google.maps.MarkerImage(“http://chart.apis.google.com/chart?chst=d_map_pin_shadow”,
new google.maps.Size(40, 37),
new google.maps.Point(0, 0),
new google.maps.Point(12, 35));
It’s basically a matter of passing a new type variable down to the correct spot. I’ll likely make it so this is easier in next version. For XML you can do the following:
After line 446 under the “Process XML” section add:
var type = $(this).attr('type');A few lines after that, where the locationset arrays are being defined on 453 and 460, add “type” to the end. Example for the first one:
Then, on line 690 add “locationset[y][14]” as the last parameter for createMarker:
In the definition of the createMarker function on line 752 add “type”:
function createMarker(point, name, address, letter, type) {Then you could do something like this (using Bank as a second type) at the beginning of that function:
if(type=== "Bank"){ var pinColorOverride = "6991fd"; } else{ var pinColorOverride = "fe7569"; }Then, on 754 where Image is defined just replace settings.pinColor with pinColorOverride.
Hi Bjorn
Thanks you so much for your reply, it all worked perfectly.
I now need to pass that ‘type’ variable through to the location-list-description.html template, so i can add the type variable as a class on the list-label div so I can match the colour to the markers I am using.
IS there something else I need to do to pass the type variable to the list template document? It does not seem to be working after implementing the changes above. Adding {{type}} in does not add any value.
Thank you in advance if you are able to help and thanks you for the plugin it is great.
James
Just a couple more things to get it to the templates:
Declare storeType as a new variable along with the others on current line 490.
At the bottom of the create_location_variables function add:
Then look for the “Define location data” comment around line 557 and in the else add the following after origin (be sure to add a comma after origin before adding the new line):
That should allow you to use {{type}} in the templates.
I assume in the latest version type has been replaced by category??? It seems to have worked for me using the category variable.
Dear Bjorn,
I love your script, because our network only support ASP as server script.
And i dont know anything about that.
So this script is the perfect solution.
I have only one problem, when i am testing the script, local on my computer.
Then the form wil not submit in Firefox or Chrome. Safari is no problem.
I can’t test IE, because it isn’t installed on this mac.
Do you have a fix for this problem.
With kind regards,
Laura (the Netherlands)
Are you running it from a directory on your computer or a local web server? It won’t run from just a directory.
I’am running it from a directory on my computer. I will try it on our webserver.
Hi,
The script is working on the server. Thank you very much.
I can’t figure out, where i can change “directions” in the results.
Because i want to change it in to Dutch.
And how can i change miles to km.
Greetings Laura
There is an option for kilometers:
$('#map-container').storeLocator({ 'lengthUnit': 'km' });For the directions text you can change that in the template files (/templates directory). If you’re using XML or JSON you’d want to edit the location-list-description.html file.
I could not get km working by parsing it in from the html file, so I just hard coded it in the end.
Hello Bjorn,
your script is GREAT!
However, how can modify this to integrate img src ?
e.g
<marker img="” name= “test” lat= “43.586117″ lng= “7.036627″ type= “” address= “6250 MOUGINS. France” address2= “” city= “” state= “” postal= “0″ phone= “” web= “” hours1= “0″ hours2= “0″ hours3= “0″/>
{{#location}}
{{marker}}
{{img}}
{{name}}
{{address}}
{{address2}}
{{city}}, {{state}} {{postal}}
{{phone}}
{{web}}
{{#if distance}}{{distance}} {{length}}
Directions{{/if}}
{{/location}}
Please i need some help to attach a picture for each ID.
Greetings Med
If you go up a couple of comments this is basically the same question that “James” had. Instead of “type” just create image variables.
I can’t seem to get the example to work for me. I’ve checked all my links and made sure I’m using the right scripts but it still won’t ‘go’. All I’m getting is a blank when I hit the submit button.
http://www.fxi.com/html/store/
It looks like you didn’t upload the templates: http://www.fxi.com/html/store/templates/infowindow-description.html
/facepalm. That was it! Thanks.
Hi Bjorn,
I have 2 questions.
first one, In IE stands the cursor on the letters. So you can
alright xD the second part disappeared.
Second one, when there is more than 60 miles in between you get a pop up. Do you know where i can change it to Dutch?
My boses are very pleased, because i found your script. So thank you very much
Second question: You can find the text in the jquery.storelocator.js on line 477 and 483. I see there’s a bug there, which should display kilometers if you have that option selected. I’ll fix that in the next version.
I don’t think I understand your first question. Do you want a different cursor for the location list?
Hi,
Some part of my question disappeared.
The question was.
In the input field for to zipcode or streetname.
The text cursor is on the last letter you typed. This allows you not see what you typed. This happens only in Internet Explorer. While Firefox and Chrome put the text cursor after the letter.
I’m still not sure I understand. Does this happen in the demo links above?
http://heditex.com//WSData/WSStyle/Bodiax/images/vb.jpg (screenshot what happens on our site)
Its only in IE.
It doesn’t happen in the demo above.
It must be some other CSS on your site. I’d try using the Internet Explorer developer tools to see if you can narrow it down.
Hi Bjorn, I was trying your demo and I wanted to know is there a way to remove the list on the left of the map and just leave the map to show the markers of the locations.
second, how can I change it to take dynamic radius. So if the user wants to see with a certain radius and there is field in the form, how can I do that.
Thanks
You should be able to remove the left list by commenting out or removing line 721:
$('#' + settings.listDiv + ' ul').append(listHtml);For the second question, please see the max distance example above.
Hi Bjorn, Sorry you mentioned looking at the max distance example, I was not able to locate which example you were talking about.
I basically have a form that takes a
- Postal code/ zip code
- street address
- country and
- radius
I want the app to look for the location within the radius specified by the user in the form.
so for example user enters a postal code or street address and selects radius of 6 miles, I want the results to be displayed within the 6 mile radius of the postal code or address entered by the user.
also if the user doesn’t enter any postal code or address and just selects a country example Canada them I want the app to display all the stores in that country.
could you please point out where I need to make changes to add this functionality.
Thank you very much and again you have done a very good job this application.
Maximum distance example: http://bjornblog.com/storelocator/maxdistance-example.html
Zip code or address can be entered into the main address field. If you want to separate them out I’m not going to be able to assist you with that.
Use the fullMapStart option if you want to start with all locations or set the zoomLevel to 0 to automatically center and zoom.
Hi Bjorn,
above is the location.xml with just one location for now. When in the setting I turned “defaultLoc” to “true” I get error popups saying unable to locate.
could you please see what’s wrong with the location address. I really don’t know why it’s not able to find it.
Thanks.
You need to set a default latitude (defaultLat) and default longitude (defaultLng) if you want to use the default location option. Please read the documentation above.
thanks, I actually didn’t notice them.
I have another question. How do I make sure that most of the closest location’s of the stores are visible. currently the location that is closest is always of the screen, in a sense that I have to scroll the map to see the marker.
I mean to ask is that, is there a way to draw the map so that some of them or even the most closest location is centered because seeing that is more important than may the other things.
Thanks once again.
Change the default zoom level with the zoomLevel option. If you want it to zoom and center automatically set the zoomLevl to 0.
Sorry the location xml is for some reason not getting posted, here is the link to the location.xml file.
http://jbcomp1920.net63.net/locations.xml
just adding the msg again:
above is the location.xml with just one location for now. When in the setting I turned
I’m facing a very odd thing right now. I managed to get a variable replaced by images(stars).
When a variable stars has a value 3 for exemple, an image of 3 stars is displayed in Infowindow and list. I made up this for 5 stars, but only the 4stars image and 5stars images are displayed.
For the others nothing happens. Can you help me to find the problem ? And sorry for my english
Problem solved !! I just had to handle the css and it worked perfectly. But another problem appeared
when I tried to put it in my Joomla site. Apparently, store locator is facing the conflict with Mootools.
Are you using noConflict? http://api.jquery.com/jQuery.noConflict/
You should definitely be using it if you’re running jQuery and Mootools on the same site.
Thank you for you answer Bjorn ! Actually the problem (still) isn’t there, cause I implemented
JQuery Autocomplete for the searchbox and JQuery simplemodal to replace alert() by modal windows. And it works. The problem is the map does not display. I’m sure that the problem is in my JSON file parsing, different in Joomla, but I don’t know to do this. I want to use it for my component.
LOVE LOVE LOVE this Bjorn! I added a list where each option value matched the markerId in the map list and added this in the “//Handle clicks from the list” section:
var selectedMarker = markers[markerId];
$(“#dealer option:eq(“+markerId+”)”).attr(“selected”, “selected”);
Is there a way that I can have the select dropdown change the item that is selected in the list?
Also, I am using latitude and longitude to pull up locations by distance… However, when the map loads it does not have the first location selected on the map.. Is there a way to have it automatically select the first location in the list and have it open up the info bubble for that location on the map?
It doesn’t select or open the first infowindow by default but it’s not very difficult to add:
On line 697 in the for loop change the create_infowindow(marker) to:
In the create_infowindow function after the last else (817) add the following to pop up the first infowindow (the first one on the list will always be the closest):
if(loc_num === 0){ infowindow.setContent(formattedAddress); infowindow.open(marker.get(settings.mapDiv), marker); }Above that, after setting the list li background colors (747) add the following to focus on the first list item, which will be the closest:
$('#' + settings.listDiv + ' li[data-markerid="0"]').addClass('list-focus');For your first question, you’re adding a drop down in addition to the list? Are you using the markerID as the option value? If yes to both of those I think you’d want to do something like this after the “handle clicks from list” code (it’s going to be very similar to that):
$(document).on('change', '#dealers', function () { var selectedDealer = $('#dealers option:selected').val(); var selectedMarker = markers[selectedDealer]; $('#' + settings.listDiv + ' li').removeClass('list-focus'); $('#' + settings.listDiv + ' li[data-markerid=' + selectedDealer +']').addClass('list-focus'); map.panTo(selectedMarker.getPosition()); var listLoc = "dropdown"; if(settings.bounceMarker === true) { selectedMarker.setAnimation(google.maps.Animation.BOUNCE); setTimeout(function() { selectedMarker.setAnimation(null); create_infowindow(selectedMarker, listLoc); }, 700); } else { create_infowindow(selectedMarker, listLoc); } });Then in the create_infowindow function I think it would be alright to change the first if statement to:
Hey Bjorn,
I was able to get the dropdown working… However, I am still having problems with it selecting the first marker on load.
I changed this:
create_infowindow(marker);
to this:
create_infowindow(marker, null, y);
and also added:
if(loc_num === 0){
infowindow.setContent(formattedAddress);
infowindow.open(marker.get(settings.mapDiv), marker);
}
It is not working however and I believe that it is because “loc_num” is not defined anywhere in the document.
If I define:
var loc_num = 0;
it will open the infowindow for the farthest location(probably because it was last to load).
Any thoughts?
Oh, I missed a step:
Change function create_infowindow(marker, location){ to:
function create_infowindow(marker, location, loc_num){I tried the hardest I could to integrate the plugin into my Joomla component but it doesn’t work.I have a problem with Json and the DataLocation settings becauce actually in Joomla, I don’t know how to use it. Any idea ? That’s Very frustrating, because that’s the only thing which cannot work in the component, and keeps me stuck on the project.
Thanks by advance to the one who will give me an answer.
Do you have a link where I can see it?
Sorry that my answer took so long, I finally solved this myself, by integrating it as a wrapper in the component installation folder. By the way I have another question: how is it possible to integrate a filter system with checkboxes, which displays and zoom on only the markers category ? Is it possible ?
Heej Bjorn,
I have a question,
By a few entries i want to add a “star”-image, in the location-list. It doesn’t have to show on the map.
Where and how can change this?
Thanks once again
Laura
I solved it myself.
Great, glad you were able to figure it out.
Hi Bjorn,
Today our website has been launched.
http://www.bodiax.com/default.aspx?wsmt=wscontent&code=Info%20|%20Dealerlocator
On this page you can find the dealer locator.
Only one little issue.
The popup marker displays something, that i dont wanna show. “star.gif”.
In the xml file, it is subject to “Hours1″.
How can i change this.
Thank you very much
That’s looking great. It looks like you’d want to remove Hours 1 from the template. Just open /templates/infowindow-description.html and remove the hours1 line (line 6).
Hi Bjorn, your plugin is really awesome, I’m experimenting with it these days and it offers an incredible depth. I really love it.
I’ve got a question, and I dunno if it’s possible…
I have a few “main” stores that I’d like to show first; it doesn’t matter the distance from my starting point. let’s say that store 1 is 40 km away, store 2 is 30 and store 3 is 60, but it’s marked as a main store too.
the normal order should be store 2, store 1 and store 3, but the one I’d like to get is Store 3 (main one), store 2 and finally store 1.
Is it possible?
Cheers!
Sorry, I’ve been really busy lately. I’ve tried a couple of things but haven’t gotten it to work correctly yet. I’m going to try to figure this out.
Thank you Bjorn for the help.
Hi Bjorn, could you please explain how fullmapstart = true works, how is it able to get all the locations in the xml file without looping.
I want to make a change where it can only get the location of a particular country selected based on the form.
Thanks
jQuery Conflict:
Hello, I’m having an issue with a theme I’m using in WordPress, which uses a different version of jQuery. When I add , the maps work beautifully but it breaks some of the functionality on the website. Is there a way to use jQuery 1.9.2 or whatever version my theme is using?
Thank you for a great script!
Also, second question that I forgot to include:
I want to add small icons to the locations list for the services specific locations have. I’m looking at the location-list-description.html template and think the best way to do it would be to have something like IF LOCATION X, , IF LOCATION Y, , etc. I’m just not sure how to put that in the template. Is it JS?
What version of WordPress are you running? WordPress includes jQuery automatically, so you don’t want to include it again. Hopefully your theme isn’t including some old version of jQuery. The proper way to set it up in WordPress would be to edit an existing JavaScript file in your theme, if one exists (there may be one for general scripts), or create a new JavaScript file and include it via wp_enqueue_script in your theme’s functions.php file or a custom plugin. You could also add it in your theme’s header or footer file but it’s not the best way. jQuery is namespaced in WordPress so you need to use jQuery instead of the dollar symbol for the call:
jQuery('#map-container').storeLocator();Will there be an icon for each individual locaiton or will there be icon categories?
Great, thank you. I’ll take a look at the jQuery files.
Each location will have a combination of services, like categories (i.e. gas station, lotto station, car wash). We just want to display the icon for the service that’s applicable to the location. I don’t mind setting the icons manually for each location.
There are the jQuery references in the theme I’m using. When I remove the one for your plugin, the site works as designed but the map is not displayed.
script type=’text/javascript’ src=’/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.9.2′>
I may just make a custom template for the location page if the theme is incompatible.
Last reply on jQuery: wordpress currently uses 1.8.3. WordPress 3.6 (scheduled for end of April) will use 1.9. Until then, I’m going the custom page route.
Any thoughts on the services category icons?
Unless there is a better way, I just added another field in the XML and will set the icons per location.
Sorry, yes – that’s what I’d recommend doing. I have a category field in the latest version of the plugin that is passed to the templates. It was previously “type” but it wasn’t completely set up.
On the jQuery thing. The first thing you mentioned with version 1.9.2 is jQuery UI, which is separate from jQuery.
Bjorn,
I’ve seen the category field in your latest version. Is it possible to filter on this field? Like you do with the max distance option?
For example:
Enter your address / zip code, select a distance and select a categorie.
Edit: Disregarded comment
Disregard that last comment, it doesn’t work. If you skip down to comments by Devin you’ll find a full example that I posted.
Hi Bjorn, Could you help me with modifying fullmapstart to only display a certain countries locations.
I want that when the page is first loaded, it should display all the location that are in Canada, even though it has locations in other countries.
Could you please give me some input in this. Thanks you
I’m not sure if it would work for this situation but have you tried setting the region as described above in step 4 under usage – “Region targeting example”
Love this plugin. I’ll be using it for a major u.s. corporations website. I’ll link you when it’s fully customized. I wanted to know how I can style the infoWindow a bit more than what’s offered in the infoWindow template file. I was hoping to change the entire look of the window, not just the contents. Example, I want to change the close X and also the way the corners and drop shadow. etc… any suggestions?
Hi, the only method I know of to change the infowindows is the InfoBubble library on this page (at the bottom of the list): https://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries
I haven’t tried working with it at all but I’ve read that it has worked for people.
Hello Bjorn,
Do you know if there is a solution to list two stores of the same location inside the map bubble?
i.e.
Store A and Store B are sharing/next to each other the same address
- show on map as A or either B (that is the current situation)
-> click on google map marker shows Store B under Store A
Thank you
That would be a more general Google Maps issue. You might find some ideas here: http://stackoverflow.com/questions/3548920/google-maps-api-v3-multiple-markers-on-exact-same-spot
Hi,
I would really like to use a custom marker on my map. I THINK Ive found where to change the pinImage, but it is not working. Could you please show me which lines to manipulate to use my own icon? Thank you so much for such an incredible plugin.
ben
It depends on how many locations you’re showing at once. If you’re using the default settings with the marker letters, the marker is set up with line 773 to 780 (assuming you’re using the latest version). Line 773 is the path to the image – you’d change what’s in the parentheses. The next line sets up the dimensions of the image and the next 2 lines deal with placement. The four lines after that set up the marker shadow. There are some more examples here: https://developers.google.com/maps/documentation/javascript/overlays#Icons
Hey,
Great job with this store locator! I have been wanting to figure out how to do this; however, I am stuck…. How do I change the Chipolte to another company and its locations and show the results?
You need to decide how you want to pull in the location data. You can create a new XML file based on the example that’s bundled with the plugin. Alternatively you can use JSON or KML. KML is easiest if you want to create a My Map on Google Maps and export the data: http://support.google.com/maps/bin/answer.py?hl=en&answer=62843
Hey,
I think I’ve got everything setup correctly. Unfortunately none of my locations are showing on the google map. I’m guessing I’m not sending all the required fields. What fields are required?
Currently, the only fields I’m sending are:
locname
address
city
state
postal
web
Do I need to add in lat and lng? Anything else? My client didn’t provide lat/lng, might be a manual effort.
Thanks,
Max
Adding a lat/lng worked! Sigh
Yep, you need to add the latitude and longitude. If you’re looking for an easier way you can sign in to Google and go to Google Maps, create a “My Map” and export the KML to use in place of XML. http://support.google.com/maps/bin/answer.py?hl=en&answer=62843
Hey Bjorn, love the plugin. I have added a recaptcha to the form, but since the form is in ajax, the map still reloads whether or not the captcha was entered. Any ideas on how I can make it work ?
I think I would try to validate Recaptcha with AJAX first. You could add it into the begin_mapping function that starts on line 250, which is where the plugin gets the form input value. I haven’t tried it myself but you might be able to work off this example: http://snipplr.com/view/15563/
Love this feature, but we have a small problem.
We are seeing some of our users typing in a CITY only – like PORTLAND.
And as a result the script defaults to the most obvious PORTLAND – Washington.
However, we are using this for a company in North West Indiana. And there is a Portland there (near Gary).
Any way, we can force it to look in a certain area “first”????
thoughts
Hello,
The search box essentially functions the same way that the search box does on maps.google.com. If you’re using this for one state I’d recommend using a more specific label on the input field to give the user more direction. You could either have it tell people to enter the state along with the city or you could just have “city” as the label and add the state to the value that the user inputs. If you want to do the latter you could add a line after line 261 (after the check for a blank value) such as:
As far as I know the Google Maps API only does region biasing based on country. If you wanted to get fancy you could do an IP lookup with a back-end language.
P.S. Oregon not Washington
Thanks for the ideas…
And, maybe I should go back to 5th grade Geography class…. Oh well…
I think we’re going to take the user input and test to see if it has numbers. If there are NOT numbers, we may assume it is JUST a City and add a state value to it.
Hi,
This is the best store locator. I have ever used. Thanks for that.
Is there a way to show the directions inside the store locator instead of going to the google maps??
Hi, the plugin is currently not capable of doing this. I may add it in at some point in the future.
hi bjorn,
i’m already using your plugin with xml file,
now upgrading to ver.1.4 i would try to use the kml file generated by google maps.
everything it’s working and my question is:
is there the way to use the icons listed in the file?
http://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png
it could be very amazing considering that we can upload our icons on google map.
tnx a lot
_
marco
arghhhh the text has been lost:
http: //maps.gstatic.com /mapfiles/ms2/micons/blue-dot.png
For KML the icons are currently not pulled but I’ll try to get that in the next version.
tnx a lot
i’ll wait for the new release to upgrade
great job
Hi Bjorn,
My bosses found a problem.
When someone put in a zip code, the locator shows them 5 results.
We have 2 kind of dealers (star and normal). When there are in one city more then 5 dealers like “Vlaardingen”. He doesn’t show any star dealer, they pay for it.
My question is:
Is it possible to put the star-dealer first in the search result in a radius of let’s say 20 km. And then the normal dealers.
http://bodiax.com/default.aspx?wsmt=wscontent&code=Info%20|%20Dealerlocator
I hope it’s possible
Hi,
Is it possible to use multiple KMLs with this? I have a KML with my store locations, but I also have another KML with polygons that I would like to overlay.
Right now the plugin is just set up to read the location data from one file.
Hi Bjorn
im trying to add a few simple categories that i can filter by the results by. i read the previous comments and tried adding if(locationset[y][14] === selectedCat){ on line 705. It seems to work sorting the markers but now my list wont display? I think i might be placing the if statement in the wrong line? Any advice would creating categories would be great!
thanks in advance!
I think I see what you mean and I’m looking into it.
Thanks Bjorn!
Here is link to an example of what im trying to do. http://weareshowpony.com/locator/ using the checkboxes filter by the 3 categories.
Here’s a much easier solution that I’ve tested and it’s working. I used a select box in my test environment but you should still be able to work off of it.
In the begin_mapping function get the value of the category that you want. Ex:
var selectedCategory = $('#category').val();In the same function about 13 lines down the mapping function is called. Pass the selected category:
In the mapping function get the selected category:
function mapping(orig_lat, orig_lng, origin, maxDistance, selectedCat){Where the locationset array is created, you’ll want to check the category before adding the location – you’ll see comments for “Process JSON,” “Process KML” and “Process XML.” So, assuming you’re using KML and you’re not using the maximum distance option, you’d make the following change around line 485 (in the else):
if(category === selectedCat){ locationset[i] = [distance, name, lat, lng, address, address2, city, state, postal, phone, web, hours1, hours2, hours3, category]; } else{ return; }Hi Bjorn,
We have dealers in the Netherlands and in Belgium.
Google maps i put on NL.
But when i search with a Belgium zip code “8550″. he shows Bulgaria.
Do you have an solution for this.
Thanks,
Laura
Region biasing only seems to accept one parameter: https://developers.google.com/maps/documentation/geocoding/#RegionCodes
Other than using some other service for Geocoding or a back-end geolocation based on IP address, I think what you’ve got up now with B-xxxx is probably the easiest solution. You could also have a country drop down in the form and change the region in the URL based on what the user chooses.
I’m looking into the other question you asked.
Hi there Bjorn,
A great plugin – really got me out of a bind!
I copied the code from the working demo.html file (which is working perfectly – I haven’t changed anything yet as I am just testing options) into a page that has two other forms on it (a search form and mailing list sign up) and even though those two formsa have separate ids etc etc the plugin won’t work if there are other forms on the page – any reason for this??
Thank you
Jan
Do you have any errors that are being displayed in developer tools or a link with an example?
Hi Bjorn,
Thanks for a great plugin but being only able to include a maximum of 26 markers is a big drawback.
It would be better if it used numbers instead of letters.
There is no limit as of 4 versions ago.
Hello. Thank you very much for sharing your work with us, this is an amazing plug in that safes a lot of time to a lot of people, like me. So, sincerely, many many thanks.
Hi again.
I’m doing that the lng and lat values aren’t mandatory in the xml locations file. Because we can get it from google, having the complete address of each store, so i don’t want to make may users search and write the lng and lat values for each store.
I have it working, but with one problem. It works wen my browser haves the xml file cached. But the first time, when it’s not cached, my stores are going to the ocean
This is my code:
//Process XML
$(data).find(‘marker’).each(function(){
var name = $(this).attr(‘name’);
var lat = $(this).attr(‘lat’);
var lng = $(this).attr(‘lng’);
var address = $(this).attr(‘address’);
var address2 = $(this).attr(‘address2′);
var city = $(this).attr(‘city’);
var state = $(this).attr(‘state’);
var postal = $(this).attr(‘postal’);
var phone = $(this).attr(‘phone’);
var web = $(this).attr(‘web’);
web = web.replace(“http://”,”");
var hours1 = $(this).attr(‘hours1′);
var hours2 = $(this).attr(‘hours2′);
var hours3 = $(this).attr(‘hours3′);
var category = $(this).attr(‘category’);
if (lat==null || lng==null || lat==”" || lng==”")
{
geocoder = new google.maps.Geocoder();
geocoder.geocode( { ‘address’: address + ‘ ‘ + address2 + ‘ ‘ + postal + ‘ ‘ + city}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
lat = results[0].geometry.location.lat();
lng = results[0].geometry.location.lng();
}
});
}
I’m not sure, I think that the callback function for geocoder.geocode function is being slow the first time, and so the process is continuing with lat and lng variables with null values.
How can i make this geocoder.geocode call to block the process until it has get the response?
Sure it’s easy, but i’m not very used to jquery, and i don’t know exactly how to get it.
And i think this is a pretty easy and useful improvement you could add to the plug in
Kind regards
Ok, don’t waste time about that. This is not possible because when you have several stores Google API returns error “over query limit”. So lng and lat coordinates are needed in the xml locations file for the plugin to work well.
But i don’t want my users to find and configure the lng and lat coordinates for each store. So I think the best idea is to have a function at server side that find out the coordinates automatically using the address filled by the user.
I wrote a C# (asp.net) function to do this, with a little (lot of
) help from some webs I found. Here is the function, for anyone who needs it:
————————–
using System;
using System.Xml;
using System.Threading;
using System.Web;
————————–
public static string GetLongLatFromAddress(string address, out string longitude, out string latitude)
{
longitude = “”;
latitude = “”;
XmlDocument doc = new XmlDocument();
try
{
doc.Load(“http://maps.googleapis.com/maps/api/geocode/xml?address=” + HttpUtility.UrlEncode(address) + “&sensor=false”);
XmlNode element = doc.SelectSingleNode(“//GeocodeResponse/status”);
if (element.InnerText == “ZERO_RESULTS”)
{
return (“No data available for the specified location”);
}
else if (element.InnerText == “OVER_QUERY_LIMIT”)
{
Thread.Sleep(200);
return GetLongLatFromAddress(address, out longitude, out latitude);
}
else
{
element = doc.SelectSingleNode(“//GeocodeResponse/result/geometry/location/lat”);
latitude = element.InnerText;
element = doc.SelectSingleNode(“//GeocodeResponse/result/geometry/location/lng”);
longitude = element.InnerText;
return “”;
}
}
catch (Exception ex)
{
return (“(Address lookup failed: ) ” + ex.Message);
}
}
————–
This function gets the coordinates from the Google API URL. With the added that if it gets the over query limit error it waits some time and retry the query.
Hope it helps.
Kind regards, and thanks for your wonderful work Bjorn.
Yeah, the limits are the reason I don’t include Geocoding with the data. Careful when using this class though – the limit is 2,500 requests per day and if you are consistently exceeding that they can block you:
“If you exceed the 24-hour limit or otherwise abuse the service, the Geocoding API may stop working for you temporarily. If you continue to exceed this limit, your access to the Geocoding API may be blocked.”
https://developers.google.com/maps/documentation/geocoding/#Limits
Hi Borjn
Will this plugin work with jquery mobile?
Can I also change the markers to custom markers like google store locator.
Joseph
Hi Bjorn
Followed this and seems to work and happy http://www.bjornblog.com/web/jquery-store-locator-plugin#comment-4050
Saw another post where to see if I can have multiple markers, if that works, then I will be more a happy boy.
Hello Borjn,
Thanks for such a fantastic tool and for sharing it!
Any chance the plugin could get it’s data feed from an array within the rendered page itself? I use a content management system called Adobe Business Catalyst. If I could adapt your plugin for use with BC, my clients could update what BC refers to as a web app to feed the “locations” output to the array when the page loads. I could make the data output by the CMS into the array mirror the layout of the XML feed as an example.
Thanks again for the fantastic plug in.
What would the file type of the output be?
Fantastic plugin! Also runs flawlessly in an iframe.
I’d like to know if it is possible to add an email address field to the XML so that it gets interpreted as a mailto: so that when users click on it, it takes them to their default email client.
If you’re not using all the location attributes, such as hours2 or hours3, you could use one of those for an email address. Then, in the template files (in the /templates directory) you could do something like this:
<div>Email: <a href="mailto:{{hours3}}">{{hours3}}</a></div>Otherwise, it’s kind of a process of adding a new attribute and passing it through to the correct places. Email makes a lot of sense though. I’ll add that to my list for a future version.
Thanks Bjorn,
I actually tried this before I posted here. I created an email=”email@address.com” field in locations.xml and defined the email display in template files same as per your instructions above, but the email address does not show.
Any other suggestions?
I noticed that to add variables the jquery.storelocator.js needs to be modified. I hacked at it but failed to make it work. Thus when you get a chance please have a look at it and add an email field. As you said, email would be pretty useful.
Borjn
it seems I just added if else statement and used the category instead of creating a type variable to load different type of markers. So so far I have two types of markers on my map for different stores.
Now to tackle infoWindow and see if I can skin it for Jquery mobile.
Any hints direction on handling infoWindows other than reading comments above.
As far as I know the infoWindows can’t be styled without an extra plugin. The InfoBubble library on the following page is one of the only things I’ve seen that allows you to do it (bottom of the list).
https://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries
Borjn
please do not say about the info window.
Hope it can be done this way.
I don’t understand your reply. Please see the details on the following pages. This extension allows you to use CSS3 for the infowindows.
https://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries#InfoBubble
Example:
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/examples/example.html
Bjorn
I think that is the example I am looking for.
I will try and let you know. Thanks for the response.
Hi Borjn
Not sure if this is a bug or not, when I change storeLimit to 50 in the javascript file, it seems to lose my custom marker settings.
Can I go over the 26 limit and still keep my custom markers
sorry index3.html shows my custom markers. As I said once I go over 26 seems to lose my markers and reverts back to default markers.
Borjn
Resolved the issue. Could my posts with my urls get blanked out or deleted please.
Sure. Sorry i couldn’t get back to you earlier. Glad you got it figured out.
Hi Bjorn,
I see in a post above that you may add geocoding to all the addresses in the future, not just the user’s address/location. Have you by chance done this?
You’re better at JS than I, so if not, would you consider it?
Thanks,
Gary.
How many locations will there be? For regular users the documentation states it’s 2,500 geolcation requests per day:
https://developers.google.com/maps/documentation/geocoding/#Limits
Only 30-40 at any one time. I checked the usage & don’t think the limits will be an issue. If it becomes one I will have a good argument for converting it to a business account.
What I have eventualy done is calculate the lng and lat coordinates only once (when user creates the store in my cms) and save it in the database, along with the address, city, …
So my users don’t have to find out coordinates, it’s made by the cms with that asp.net function i posted and then saved in the data base.
This way it’s only one query one time, so it makes no problems with Google API limits
Thanks @ManWithNoName, I appreciate the insight. Normally I would follow the same path, but in this case the CMS is a closed ERP system, which doesn’t even offer the lat/long fields. I can get names, addresses & phone numbers, but that’s about it.
Bjorn: any thoughts on adding the geocoding option to all the addresses?
Thanks,
Gary.
Hi Bjorn
I want to explain to problems i had using the plugin with asp.net. Maybe you would want to solve it for next version.
The problem is about having more textbox and buttons in the same page. If you want to have buttons that make postback in the same page the store locator is, you need 2 changes:
1. Name and id of the button cannot be “submit”, because it causes an error on postbacks. Just an asp.net restriction. If you do so, you get an error on postback on line theForm.submit(); of asp.net javascript function __doPostBack(eventTarget, eventArgument).
So i changed to:
2. The keyup event is attached to document, so all postbacks make with an enter key launch the store finder button event, and since the textbox use to be blank, then the blankInputAlert appears.
This should be changed, like this:
//ASP.net or regular submission?
if(settings.noForm === true){
$(document).on(‘click.’+prefix, ‘#’ + settings.formContainerDiv + ‘ #btsubmit’, function(e){
get_form_values(e);
});
$(document).on(‘keyup.’+prefix, ‘#’ + settings.formContainerDiv + ‘ #’ + settings.inputID, function(e){
if (e.keyCode === 13) {
get_form_values(e);
}
});
}
Hope it helps. Regards
Ups, no html allowed. I meant, i changed the button to:
input type=”image” id=”btsubmit” name=”btsubmit” src=”images/submit.jpg” alt=”Submit”
Bjorn,
I just have read all the comments but didn’t find an answer!
How can i rezise the map? Someone?
The map is set up to stretch to the size of the div with the id of “map.” If you look at the CSS file you’d want to change #map-container and #map.
Hi Bjorn!
Very useful plugin, really liked it. I am trying to embed it but I got few questions to ask since I’m not into this jquery.
First of all, I tried to set my default opening map (or center location) but I couldn’t make it.
Or maybe I want to by-pass this zip-code locator. I just want to center the map on a city that I’m going to use and put some places to pin.
Could you please help me?
I think the best way to do that would be to use the defaultLoc option and also set the zoomLevel option to 0. Use the default location example to get you started. Example:
$('#map-container').storeLocator({'slideMap' : false, 'defaultLoc': true, 'defaultLat': '44.9207462', 'defaultLng' : '-93.3935366', 'zoomLevel': '0' });Hi Bjorn, first of all thank you for your interest.
I tried your suggestion but when i add zoomLevel to that line, it wants an input(zip or address) and It doesn’t work even I give zipcode info.
I’ll just use defaultLoc example, but It would be awesome if I could arrange that zoomLevel.
Best regards,
kiv
Thanks Bjorn,
I’ve found it. Just still one question.
How can i handle the error ZERO_RESULT, i want to display some other text.
That’s an error from Google and it’s not something you can change. Have you set up the data file with all the locations?
Hi, first of all sorry about my bad English
I’m using this wonderful plugin in a furniture website, so it will list the affiliates of this company.
However i would like to know if there’s anyway when i select a city shows in the div “listDiv” just he affiliates that belong to this city and not the others.
Eg. (like is in yout demo):
I select the city Plymouth, in div “listDiv” he shows just the affiliates that belong to Plymouth, and hide the others (like the affiliates in city Edina).
I don’t know if you understand,
Hope you help me, please!!!
I think I understand what you are trying to do and I think it might be best to have a drop-down select field with the main cities. If you follow the example that I posted in the discussion with Devin above it should be very similar:
http://www.bjornblog.com/web/jquery-store-locator-plugin#comment-15026
Ok, i’ll try this and tell you if it works!
Thank you very much
Hey.. this plugin is awesome – really simplifies the painful job of working with Google Maps!
I’m having one small problem where everything looks/works great, but infoWindows don’t show onClick.. no error appears in the console.
Any ideas/thoughts greatly appreciated!
What version of jQuery are you running and do you have an example link?
hey Bjorn,
i know some people have asked this question before … can you post an example of how to push results to another page or did you do it already and I missed it?
Thanks in advance
Hi Bjorn!
You did an excellent job with the plugin!
I am working on a phonegap project and i decited to use your plugin. The pluging works great on iPhone, but not on android. On android when i try to write in the text area and send the address with the button a white screen pops up and the whole plugin collaps. Have you got any idea what could cose this problem ? I am useing jQuerymobile framework and Adobe phonegap build.
Hmm… are there any errors to work from? I’d start by making sure the templates are loading – is there maybe something different with the paths?
Hey Bjorn, is there anyway I can include GET variables in the location.xml file? What I am doing is generating my XML file via PHP. I renamed the file gen_default_map.php and what I need to do is pass the users current coordinates into the url so that I can query the mySQL database to get the closest business within a 30-mile radius. The problem is with the way the script is written. I can’t simply inject the user’s Geolocated coordinates.
I’d like the URL to read something like this: data/gen_default_map.php?lat=34.383747&lng=-82.364574&radius=30
Here is the code I have written to get the user’s coordinates, and if it can’t generate the coordinates, the PHP file defaults to a particular location.
———————————————————
var LocationGlobal;
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(position)
{
var lat = position.coords.latitude;
var lon = position.coords.longitude;
LocationGlobal = ‘data/gen_default_map.php?lat=’ + lat + ‘&lng=’ + lon + ‘&radius=100′;
alert(LocationGlobal); // Sets correctly here
});
} else {
console.log(‘Error getting coordinates.’);
}
// alert(LocationGlobal); // Undefined here
———————————————-
How can I write your code to make it generate the user’s geolocated coordinates in the xml file?
Sorry for the late reply, I’m a little confused by your post but I think I understand what you are trying to do. If you want to just feed in the lat/lng from a query string parameter you could use some javascript to get the query string values and then edit line 270 to 281 to something like the following (make sure to set olat and olng). The origin address is needed for the direction links.
olat = latitude; olng = longitude; var r = new ReverseGoogleGeocode(); var latlng = new google.maps.LatLng(olat, olng); r.geocode(latlng, function(data) { if(data !== null) { var originAddress = data.address; } else { //Unable to geocode alert(settings.addressErrorAlert); } }); mapping(olat, olng, originAddress, distance);My application is one where there are many store locations (franchises) within close proximity. The problem arises when a customer is searching for a store within a specific city name or specific zip code, and instead the function returns the closest store, even though there are matches within the requested city or zip code. I assume this is because the plugin geocodes the user-specified location, which is some form of center of the city or zip code, and then orders the return data by proximity to that location. Because different franchisees own and promote their businesses, when a user searches for the store in CityA, the CityA franchisee is more than a little angry when CityB’s store shows up first in the list. In fact, there are many cases where NO search will yield CityA’s store as the first in a list, because CityA is further from the located center of any zip code or city. Do you have any provision for correcting this? It would be nice of exact matches to the searched city or zip code came first, regardless of calculated distance.
I understand what you mean but how would the locations be sorted if, for example, you wanted to display all the locations within 1 zip code? As far as I know, when you geocode a zip code the latitude and longitude point will be the center of the zip code area. Unless there is a more accurate starting location there would need to be some kind of alternative sorting method. The easiest solution would be to have the input field label set to just “street address.” The plugin currently sorts by only the distance.
Ok, I don’t know if it’s normal, but when you put the autoGeocode:true… you can’t put maxDistance:true. I want to be able to get the Geo location when you first arrive on the page and then you can search with a max distance… Is there a way to do that?
The only thing I found is to put this line:
var maxDistance = settings.distanceAlert;
after the line 486. That way it define the variable with the maxDistanceAlert settings…
Do you have an other way to do this?
Thanks
I wouldn’t really recommend doing this. With the autogeocode option turned on, it starts processing immediately after you agree to share your location. If you stopped it after that, it would just be another step that the user would have to take. I could see if I could make it work so that the user could change the max distance after after everything has processed but I don’t really see a good reason for doing it.
Hey Bjorn,
If we are using a json file, is there any way to keep people from navigating directly to the php file and see all the json records in their browser? I tried using htaccess, but then the map won’t populate either.
Thanks for any help!
I think I’d try using a cookie or session variable. Set a value when the visitor views the page and check that value in the other file before outputting the data.
Everyone who uses this plugin schould make a donation to Bjorn!
I will do!
This is a great plugin! Thanks for making it available.
I am having one issue: I’d like to load my XML file from a different domain, but I can’t get this to work. My XML always has to be hosted on the same domain for the script to function. Am I going crazy?
Looks like I’m running into the same origin policy. My site is hosted on Shopify, which means the page URL looks like http://site.myshopify.com but the assets are stored on http://cdn.shopify.com what can I do to get around this problem?
I ran into this same issue. Shopify is unable to add a cross origin to cdn.shopify.com for your asset folder, so you cant call in your .kml form there. Our workaround was to use Amazon S3 to host that asset, which allows you to easily set up a cross-origin policy for shopify.
Caroline @shopify also had this clever workaround idea:
“You could also have your client paste the content of his KML to a page in his shop, then use my solution here: http://stackoverflow.com/questions/8743045/how-to-create-an-empty-html-file-in-my-shopify-website.
Key point is to use {% layout none %} in the page template you’ll associate to the page. That solution speaks of an HTML file but the same is true if you need a XML, CSV file, any type of file which has UTF-8 content, including a KML file.”
Did you use JSONP to grab the asset from Amazon S3?
Wow okay, I finally figured this one out. Made a new bucket on Amazon S3 that contains the external resources. Used the CORS rules to allow GET requests, see doc: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html
Now it works perfectly
Hey Bjorn, is there an option to add a google map cluster or any help on how i can add that to the map? Great work on this. Thank you
I haven’t done anything with clusters at this point. I can look into it.
Hi. Thanks for this. can you please confirm there are script errors after you click on a link (web address, which opens new window). I have checked this in Firebug across all your demos. Any subsequent click produces script errors.
Sorry, I’m not sure what you’re talking about. Can you be more specific and paste the specific error you are seeing?
Hello, really great plugin, thanks for creating this.
One thing I’m trying to figuring out though: I’m using Laravel 4 as framework and I have 3 different languages files that I use for my website. I would like to display the store locator map in the language they user prefers. Could you give me any suggestions where or how to start trying to accomplish this?
Cheers and thanks again!
You might be able to do this just by passing different options to the plugin. They aren’t documented above yet but there are options to override the text of each alert and the miles and kilometers text (look at lines 57 to 65 for the options names). For the actual location data you could have 3 separate data files or generate XML or JSON with the translated location data. If you have the country code available you can also add the region parameter to the Google Maps call for region biasing (step 4 above). There isn’t any actual text in the template files other than the Directions link – I should fix that and make it an option too now that I look at it.
Hey Bjorn, +1 on clusters!
Also it would be very nice to have the option of loading map styles and specifying custom markers so you can get away from the generic looking map. Does not look easily possible right now as markers paths, etc are hard coded – or do you have any samples?
Great work.
Yeah, I looked into adding custom marker options but kind of hit a dead end (if you look at the changelog I have a note about this in the version 1.4 description) in terms of the better options. You can change the markers without too much trouble but you would have to modify the plugin file – you’d want to check out the createMarker function that starts on line 781. There are also some comments above about doing some different thing with the markers based on category.
Also, I don’t know if you’ve been paying attention to Google I/O the past couple of days but Google did reveal the next version of Maps and it looks much better. I think they said it will be released in August.
Apologies – this is embarrassing. It seems its quite intermittent (atleast for me). I came back to it this morning, and I cannot replicate it. I will post again if/when i find the error.
Thank you for replying – I really appreciate it. And thank you for a wonderful store locator plugin!!
http://www.imagehousing.com/image/1131645
(copy paste of error from firebug ->)
Error:
http://maps.gstatic.com/intl/en_us/mapfiles/api-3/13/0/main.js/eval/seq/7
Line 14
It has come up – it seems an error to do with Google Maps api.
What i did:
- open the demo page – http://bjornblog.com/storelocator/
- search for ‘edina’
- click on the website url http://www.chipotle.com
- go back to parent page
- clicking anywhere produces the error
That’s strange, I can’t seem to reproduce this. A few things:
- Are you using the latest version of Firefox and Firebug?
- Can you also make these errors display with Chrome developer tools?
- Does it still happen if you close the Chipotle.com tab and then click around?