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 and will be in the /dist directory
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. You will need to geocode your locations beforehand or use a geocoding API service if you want to try to do it on the fly. The reason for this is that all free geocoding APIs have strict limits that would easily be exceeded. In the end, you’re much better off storing the coordinates versus having to look them up for each location on each request.
A note on the distance calculation: this plugin currently uses a distance function that I found on the blog of 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. For v2 I also tried experimenting with the Directions API to request distances but also found the limits to be too restrictive. So, the distance calculation is “as the crow flies” instead of a road distance calculation. However, if you use the inline directions option that does provide the distance that’s returned via the directions request.
Last, it’s very important to note that the plugin requires the Handlebars template engine. This separates the markup of the infowindows and location list elements so that they can easily be restructured. Handlebars pretty slick, will read Mustache templates, and the built-in helpers 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
It is much easier to maintain the current list of options on GitHub vs. a gigantic HTML table, which is why I’m now including the options.md file in the repository. If you need to view options for a previous version please view the old options page.
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="assets/css/storelocator.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="https://code.jquery.com/jquery-1.11.2.min.js"></script>
3. Include the latest version of Handlebars.js (this is now required)
<script src="assets/js/libs/handlebars.min.js"></script>
4. Create a new Google Maps API key and make sure to enable Google Places API Web Service, Google Maps Geocoding API and Google Maps Directions API for the project in the Google API Console after setting up the initial Maps key.
5. Include Google Maps API with your key. If you want to target a particular country add “®ion=” to the end of the URL followed by the country code.
<script src="https://maps.google.com/maps/api/js?key=yourkey"></script>
Region targeting example:
<script src="https://maps.google.com/maps/api/js?key=yourkey®ion=UK"></script>
6. Include the plugin file:
<script src="assets/js/plugins/storeLocator/jquery.storelocator.js"></script>
7. Apply the storeLocator plugin to the map-container div.
<script> $(function() { $('#bh-sl-map-container').storeLocator(); }); </script>
8. Make sure you have the basic form and map container HTML set up or copied from the example file.
Geocoding:
To geocode all your locations you can use a free or paid 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 with MySQLi and use something such as:
$results = $db->query("SELECT * FROM locations"); $locations = array(); foreach($results as $location){ array_push($locations, $location); } //Output JSON echo json_encode($locations);
Then you’d just set the dataLocation setting in the plugin directly to the PHP file and the dataType setting to json.
Support:
I’ll try to answer basic questions and create more examples but my time is limited.
- Demo example
- Modal window example
- Default location example
- HTML5 auto geocode example
- KML example
- JSON example
- Maximum distance example
- No form tags example
- Bootstrap (responsive) example
- Category filtering example
- Custom category markers example
- Inline directions example
- Name search example
- Pagination example
- Raw data example
- Query string example
- XML format example for location data
Tutorials
- Using the jQuery Store Locator with thousands of locations
- Using query string parameters with the jQuery Store Locator
Cardinal Store Locator
Donations
Some people have asked to donate. Feel no obligation but if you want to my Paypal email is bjorn2404@gmail.com and I also have a Bitcoin address set up: 17ueYyfaxCyEXedecVnr3w7GjM9PJD4CHj
Special thanks
My initial motivation for creating this jQuery plugin was a custom implementation request of my older JavaScript locator for Phin & Phebes Ice Cream. If you’re on the east coast be sure to seek out a pint.
Oops! We could not locate your form.
Hi Bjorn,
Love love love your plugin! It’s truly powerful and easy to customize for a no Javascript experienced designer 🙂
I just encountered a rather strange problem, when implemented the “Modal Example” on my website, the map in the modal wouldn’t reload when I drag around and showing a lot of grey area. It only reload when I hit the + or – button on the map, and these buttons are displaying strangely as well.
I’ve tried everything before coming to you, but couldn’t find any difference between my website and the example you gave.
Would you be so kind to take a look for me when you can?
Here’s the link: http://sunstar-tw.com/biking/brands/shimano/shimano-lsg/index.html
Type in “Taipei” on the bottom right corner and hit the button to call out the modal, try dragging the map around and you’ll see what I mean.
Thank you for the best store locator plugin and your help 🙂
Best wishes,
Fiona
Hi Bjorn,
Latest update, I solved the problem!
For future reference, the not reloading map and the strange zoom-in / zoom-out button was caused by some CSS,
and here’s the fix:
.gm-style img {
max-width: none!important;
max-height: none!important;
}
Hope this helped 🙂
Regards,
Fiona
Hello, yes several of the front-end frameworks globally set max-width for images to 100%, which makes sense for responsive web development but causes problems with Google Maps. I’ve also experienced issues with box-shadow and border-radius applied to all “content” images. I’ll be including some additional CSS in the next version to try to prevent some of these issues.
Hi Bjorn,
Absolutely loving your plugin! It really is fantastic.
I’m trying to implement some custom styling for the map using snazzymaps : https://snazzymaps.com/style/151/ultra-light-with-labels
But running in to problems. Any help or assistance would be gratefully received.
All the best, Tom
Hi,
I’m also in Tom’s predicament. Any help would be appreciated.
Thanks, Gabe
Hi Tom,
I figured it out!
Around line 28 in jquery.storelocator.js, you have to do as follows:
‘mapSettings’ : {
zoom : 12,
mapTypeId: google.maps.MapTypeId.ROADMAP, /////////////////ADD COMMA HERE
styles: [{…….]}] //////////ADD THIS LINE FROM SNAZZYMAPS
},
Hi Bjorn, thank you for the plugin.
I would like to change the colors of the map (landscape, road and water), but everything I try I did not succeed.
I’ve tried to create a styles inside the $(‘#map-container’).storeLocator({‘mapSetting’ , for example, but is not working.
Do you have any hint, I mean any code I can use?
Thanks,
Tibi
Hello Bjorn!
This tool is truly phenomenal, thank you for your work.
When an item is clicked in the list, is it possible to load another template in addition to the infowindow template? Essentially, I want to create another template that loads beneath the map, which contains further details related to the selected item.
I am stumped on how to do this, so any help you could give me would be greatly appreciated.
Thanks!
Hello Bjorn!
My ‘nameSearch’ works well but how to display the whole map again when a user search have not result (maybe with an alert too)?
Thanks
Hi,
Thanks so much for developing this! Would you or anyone know of a way I can implement this in Shopify? I’ve been trying for a while, but so far I haven’t been able to get it to work. Once I enter the zip code and click submit, I get Page Not Found.
Kenny
Do you have an example link that I could look at?
Awesome plugin only I’ve just noticed a tiny issue on iPad. This could be Google Maps JS or a Z-Index issue but if you have tapped the input box and it now has focus, clicking outside of this (the text above for example) the keyboard doesn’t dissapear, it’s as though the input covers the page and cannot be deselected etc…
Just tweeted you but makes sense to post here as I have more than 140 characters!
I’ve looked into this and it seems to be the default iPad behavior from what I can tell. I tried a couple of techniques with blur() but was unable to remove the focus. I’m not sure if there’s a way around it.
Hi Bjorn,
Thanks so much for this plugin, it is great! I would like to know if there’s a way to put in the place of the website of the store, the word “website” and this be a link to the corresponding website page.
Regards,
Dario
I’ve figured out how to fix this, if someone has the same issue, you’ve to go to the template file that is in /assets/js/plugins/storeLocator/templates/location-list-description.html and change the line 11:
Website
Regards!
And also add something like this:
$(“div.loc-web a[href=”]”).hide();
$(“div.loc-web a[href*=’facebook’]”).text(“Facebook”);
Hi Bjorn hope your well. Many years ago you helped me out with a database version before you released the one available now and I have to say it has worked superbly, really great piece of code.
I am looking to revise my website and wondered if it would be possible to use the modal window version but have custom content loaded into right pane instead of the map?
I wanted to load the location list as usual in left pane, when a url is clicked from this list it loads the store content in right pane, this could be either inline content or html page content?
Hope you don’t mind me asking before I dived in and spent hours trying 🙂
Hi Bjorn, so far Ive managed to hide map and load custom content in right pane using iframe, not ideal I know but cant quite work it out how to load into the div itself.
The problem seems to come when I try to target that iframe in the list, I can set it to _blank, _self etc but not the actual iframe name of ‘iframe_a’. I change the target in ‘location-list-description.html’ but it doesnt load anywhere.
Am I heading in the wrong direction here, should I be attempting to load content into a div in the modal?
Sorry I know you must be very busy
Hi Gary, the issue with doing that is it’s actually against the Google TOS to use their geocoder and not display a map. Geocoding is used to get the coordinates of the user’s location and reverse geocoding is used for directions. If you were to use a Google Map somewhere else on the site, I’m not sure if that would cover it or not – seems like kind of a gray area. In this situation I’ve actually used Bing’s API, which seems slightly more flexible with this kind of thing but it would require some custom work. At some point I’m going to release a Bing Maps version of the plugin, which is about 80% done but a WordPress version is my top priority right now.
Thanks Bjorn, will keep checking back.
Hi Bjorn, I would like to know if it is possible to modify the Street View controls, since there is an option to modify the mapSettings. This is the code I have:
$(function() {
$(‘#map-container’).storeLocator({
‘mapSettings’:
{
zoom: 10,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT },
mapTypeControlOptions: { mapTypeIds: [ google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.TERRAIN], style: google.maps.MapTypeControlStyle.DROPDOWN_MENU, position: google.maps.ControlPosition.TOP_RIGHT } },
});
});
What I want to do is modify the google.maps.StreetViewPanorama (https://developers.google.com/maps/documentation/javascript/examples/streetview-controls) and change this: addressControlOptions: { position: google.maps.ControlPosition.BOTTOM_CENTER } (per default it is located at the TOP_LEFT.
Also I would like to know if is there an option to add a google map cluster or any help on how can I add that to the map?
Thanks!
I am using the plugin and I have search form on my page (for searching nearby stores). Plugin is working nice upon initialization but how I can reload the data after submitting the search form (ajax call) ?
Is there any method?
Or should I destroy map and rebuild it? How ?
If you use the fullMapStart option that will initially show a map with all the locations and then people can search. Otherwise, you could call the processForm method again, which is public after submitting a form or clicking on a button:
With category filters, it is my experience that when you check one category it will include all results for that category if present in the xml / json category element. If you check an additional unrelated category, only multi xml/json category elements will show; all singular original data is disregarded and not combined in the filtered result. I see from xml/json elements sometimes one, sometimes two categories are present there. Obviously this is due to the way filtering is applied to the xml / json element. Is this your experience? I think it would be better to handle category filtering based on single and multi category elements per mapping item. Do you have work around for this or is it a bug this end. All the best.
I’m not sure I understand your question but please see the exclusiveFiltering option as it may cover what you’re looking to do.
exclusiveFiltering is what I needed, thank you for pointing that out!
Great plugin. Many thanks for this.
I wanted to add auto complete (location shows as you type). Do you have an example or could you guide me on how do I go about doing that?
Btw, my web development skills aren’t that great.
It’s not currently built in and I’ve been on the fence about adding it because if you don’t know the exact location name, there doesn’t seem like a great reason to include it. However, there is a good chance I’ll add Place Autocomplete to an upcoming version. I don’t really have time to detail how to set this up at the moment.
Congrats on the WP version, it looks great!
Places Autocomplete would be a nice addition.
The only other thing I am working on is adjusting the CSS specifically for the custom filtering option so that the map shows up in full on smaller screens. Currently I’m having to scroll down to see the full map on a 1366×768 screen. I also have a lot of checkboxes taking up a little too much space.
Would you like some extra hands on the WordPress version?
Thanks, but I’m quite sure that I’ll be releasing this weekend. Keep an eye on CardinalWP.com.
Great stuff Bjorn! Will most definitely be making a dev purchase at some point!
Hello Bjorn
How would I modify the infowindow-description.html to show an image of my store and also add an internal link to a spot on my web site.
your code:
{{#location}}
{{marker}}
{{names}}
{{address}}
{{address2}}
{{city}}{{#if city}},{{/if}} {{state}} {{postal}}
{{phone}}
{{niceURL web}}
{{#if distance}}
{{distance}} {{length}}
Directions
{{/if}}
{{/location}}
It depends on if the images/links are going to be the same for each location. If they’re going to be different add a new attribute to your data with the full path of the image (same for a link) such as storeImg=”http://pathtoimage”. Then in the Handlebars template you can use a conditional to see if the attribute has a value (if) and then output it in the markup like:
If they’re going to be the same just put the img markup with the full URL to the image.
As an adition on the above,
I like to show conditional data if a value of an object “is like ”
example: i like to show different images when different categories are selected: xml data produces
case 1 category=”a,b,c,d”
case 2 category=”b”
case 3 category=””
case 1 and 2 produces now the showing of the image when using the following code
{{#if category}}
{{/if}}
However i like to have something like this
{{#if category=”a”}}
{{/if}}
Can I use handlebars conditional statements inside the xml file that the locator js calls for?
Thanks!! Great script btw.
Nevermind…I figured it out!
What a great tool
@Bjorn, any idea how i can target the storelocator page with a search from an extern (same website) page.
I did try to fill in any form fields and trigger autosubmit with javascript put then nothing is posted (pages refreshes)
i see, i use an old version. Let me first try to update
Hello Bjorn,
Thank you for the great plugin and very useful for us.
when we have doctors name have to same Postal code we want the first to be show base on alphabetic order. It is possible?
Thanks
PraKASH
You can add this function in the plugin:
sortAlphabetically: function (locationsarray) {
this.writeDebug(‘sortAlphabetically’,arguments);
locationsarray.sort(function (a, b) {
var sa = a.title;
sa = sa.toLowerCase();
var sb = b.title;
sb = sb.toLowerCase();
if(sa sb) {
return 1;
}
return 0;
});
},
// add this function
if (typeof origin !== ‘undefined’) {
_this.sortAlphabetically(locationset);
}
// also you can comment the code for sortNumerically function call
Hi. This doesn’t seem to work for me. I have done it a few times and I always get the order by distance instead of Alphabetically.
Can you confirm that they are no mistake here:
sortAlphabetically: function (locationsarray) {
this.writeDebug(‘sortAlphabetically’,arguments);
locationsarray.sort(function (a, b) {
var sa = a.title;
sa = sa.toLowerCase();
var sb = b.title;
sb = sb.toLowerCase();
if(sa sb) { —– SEEM TO BE AN ISSUE HERE —
return 1;
}
return 0;
});
},
Thanks!
Found the answer on another post:
changed the “distance” to “name” in the function sort_numerically
part of the jquery.storelocator.js
This will filter the results alphabetically instead than giving results by distance.
Great plugin!
Dear Bjorn,
Thanks for your plugin, I love it!
I have only one question, when I enter a ZIP Code it only looks for in the United States.
Can I change that so I can look up Postal codes in Belgium?
Thanks in advice,
Nicolas
Yes, use the region URL parameter described in step 4 above with the “be” country code.
@Bjorn, we love the store locator and use it on our site. We just started applying a mileage limit (75 miles), and if you allow the browser to detect your location, you get zero results. As soon as you enter an address, city or ZIP code, the results are as expected. Can you think of a reason why the browser geo-location API would fail if maxDistance = true?
Trying to get this to load in a bootstrap modal without the zip input first, but my map doesn’t load in until i resize the browser, does anyone have any insight to help me fix this, TIA
http://www.staging.westealshare.com/Dev/nva/site/index_test.html
Hello there, is it possible to hide the ‘miles’ & directions link in the results panel?
Many thanks
Please ignore I have found it now 🙂
Hi Bjorn,
fantastic tool!!!!
But i have one Problem:
In a HTML-File it works:
http://www.thomasengelbrecht.de/miee/geo_miee.html
When i integrated it in my template (CMS: Redaxo, Responsive-Design) it don’t work:
http://www.thomasengelbrecht.de/miee/5-0-Mie-Partner-Salons.html
Did you have an idea?
Sorry, my english is very bad 🙂
Thomas
Hi All,
I have 2 questions.
1- how can i change the image fpr the origin marker. usin the param originMarkerImg.
I have tried
originMarkerImg: ‘path/to/Img’
But it doesnt work.
2- How to stay focus on origin location when no results is found.
Currently the whole map it zoomed out showing 2 markers. one on the center of the earth and the 2nd to the origin position.
thanks
Hello again, just a quick one, does anyone know if its possible to output location list horizontally rather than vertically? I only output the closest 3 locations, this happens using the autogeocode on load and appears under my main nav?
Thanks
It’s all just CSS styling so you can change the layout how you want.
If you perform a standard search using the category filtering function the no results are buggy. For example, do a search in ‘Edina’ and all the results are returned okay. Next filter the results using the first three radios “Restaurant, Bar, Cafe.” The final no results map marker is showing somewhere off Africa (I guess 0,0) yet the info window is populated with Chipotle Chanhassen’ info. Is there a fix for this? Thanks.
Thanks, I will look into this.
Thanks it does need attention. Good work btw!
Hi Bjorn,
I am using this awesome plugin. I am using this plugin for Australia. Using that, if I search Melbourne, it is redirecting me to Melbourne location in US and I am unable to search using AU Zip codes. Is there a way to resolve these issues?
And I have a typical requirement of location clustering, say grouping 5 stores which are nearby and show the number on the cluster map icon. Is it possible using this plugin?
Hello,
Please see step 4 in the directions above for adding the region query string parameter. I haven’t added clustering yet but someone on GitHub has got it to work with a modification in the past: https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/issues/33
I implemented clustering as per github’s example, however that example is not ready for product. I haven’t had time to get into the code, but it doesn’t handle the info window events correctly. Normal clustering [obviously the window port is at max zoom out for clustering to take effect], will allow you to click a side menu item and that event will cause the clusters to split as the individual marker fires, and it’s info window opens. Nothing happens like that with the github hack. Just for your information.
Hello,
Thanks for your reply.
We figured out a solution for this with a one line code. We used the marker clusterer plugin.
//clusterer code
var markerCluster = new MarkerClusterer(map, markers);
The above code should be used just after the end of the creating markers list (infowindow).
// Add markers and infowindows loop
for (var y = 0; y <= storeNumToShow – 1; y++) {
I’ve spent a few hours trying to get the clustering to work but with no luck….does anyone have a working example somewhere? what exactly do I have to change to make it work. I’ve tried to add the code from the above comment but I’m not sure where it should be exactly and when I add it my map just doesn’t load. I’ve managed to get the clustering to happen but then the info window events don’t trigger when clicking on the side menu. Is a separate js file needed or is clustering now a part of this plugin?
Hi Kiran, How did you resolve the Australia issue and search by AU postcodes only? I’ve added region=AU parameter and that helps with most postcodes but some postcodes are still showing places from other countries, eg Sydney (2000) brings up a place in Mexico. Unfortunately, most of my client’s locations are in Sydney!
Hi, Is it possible to have the results be sorted by the Road Distance Mileage instead of the Crow Flies Mileage and also list the Road Distance Mileage in the results instead of the Crow Flies Mileage?
Thanks
It’s not built into the plugin but the Google Maps Distance Matrix API is what you’d want to use if you’re wanting to make a modification. It may be something I add in a future version.
Hi Bjorn, I am using the auto geo location which prompts the user to accept its location, is there any way to put a placeholder in the location list for those that don’t see this prompt or simply choose no?
For example some text saying “Please accept geolocation for me to be able to find your closest store or click here to search
Thank you
Well, the search form is still there so if people don’t see the prompt or click no I would think that might be enough. You could also just change the input label or add some text to the search form with what you’ve described. There isn’t a built-in way to add text like that to the location list. Also, you can edit the prompt that comes up if someone says no with the autoGeocodeErrorAlert setting.
Hi Bjorn,
Thanks for an awesome script.
Any way to change the results infowindow to the left of the map?
Thanks!
Hi, yes you will want to update the location-list-description.html file that’s found in /dist/assets/js/plugins/storeLocator/templates/
Great plugin! I’m loading a list of about 100 locations in via JSON. I would like the lap to display zoomed out with all locations displayed when first accessed, but then only show the nearest 10 locations when searching for a location. I am using fullMapStart=true, fullMapStartListLimit=100, and storeLimit=10. However, when the page is first loaded, it only shows 10 locations. It is as though the fullMapStartListLimit is not being obeyed. Any tips?
Looking into this, looks like there’s a bug.
This issue should be resolved in v2.5.0
I’m also facing same issue as Scott described in parent of this thread. I have also upgraded my plugin to latest version of jQuery Store Locator Plugin. Have this issue fixed yet?
How can I target the store locator from a search on a different page or popup?
Great work btw!
Check out the query-string-example directory within the dist directory for using the plugin with a query string URL.
Ohh I see, I totally missed that. Cool, thanks!
One more question. How can I trigger the geocode on button click? (Instead of it being automatic).
Nevermind, I think I got it. Thanks again.
Hi Bjorn, great plugin!
Is the origLat and origLng still sent in $_GET by default in the newest version? I read your tutorials about thousands of locations and string query parameters, when I dump $_GET there are only two parameters “bh-sl-address” and “bh-sl-maxdistance”. Actually I need the origLat and origLng to narrow down the search scope and generate a json through PHP.
Not if you’re using query string parameters. The origLat, origLng and origAddress are passed with the default AJAX request when you submit the search form, which begins on line ~467. If you’re using query string parameters you’ll probably want to grab the value from the query string and do a separate PHP geocode request to get the coordinates.
I’m trying to have the map load with a default location, but then give the user the option to click to locate. The way I currently have the code, the map loads fine with the default location (no auto geocode), but if I click on my button to locate, the map refreshes to the default location without the autogeocode.
It almost seems as if since the default location was used at the beginning, the auto geocode won’t run afterwards.
The XML generator file doesn’t run, and the browser doesn’t ask for a look-up.
If I use Chrome’s sensor feature to spoof my location, clicking on the button would still bring me to the default location. Any thoughts?
Find Me
jQuery(function($) {
$(‘#bh-sl-map-container’).storeLocator({
‘dataType’: ‘xml’,
‘dataLocation’: ‘http://’ + window.location.host + ‘/phpsqlsearch_genxml.php’,
‘infowindowTemplatePath’: ‘http://’ + window.location.host + ‘/infowindow-description.html’,
‘listTemplatePath’: ‘http://’ + window.location.host + ‘/location-list-description.html’,
‘KMLinfowindowTemplatePath’: ‘http://’ + window.location.host + ‘/kml-infowindow-description.html’,
‘KMLlistTemplatePath’: ‘http://’ + window.location.host + ‘/kml-location-list-description.html’,
‘slideMap’ : true,
‘defaultLoc’: true,
‘defaultLat’: ‘40.7530551’,
‘defaultLng’ : ‘-73.9930989’,
‘autoGeocode’: false
}),
$(‘#locator’).click(function(){
$(‘#bh-sl-map-container’).storeLocator({
‘defaultLoc’: false,
‘defaultLat’: false,
‘defaultLng’ : false,
‘autoGeocode’: true
});
});
});
I think enough people have requested this that I’ll be adding it to the next version.
Thanks!
In the meantime, I added a Locate Me button that refreshes the page with a ?locate string on the url and this in the script:
‘defaultLoc’: false,
‘defaultLat’: false,
‘defaultLng’ : false,
‘autoGeocode’: true,
?>
And this works. Annoying that the page has to refresh, but get the job done.
Any ideas on how to capture the origin address after the geolocate/geocode? It would be great to show:
45 Locations near “the auto geolocate address(origin)”.
The top of my example was a php script saying “if _get = [‘locate’]” then show the geolocate code instead.
I’ve just pushed v2.5.0 of the plugin which includes a new geocodeID setting to trigger the HTML geolocation API with a button.
Hi Bjorn
Thanks for this great plugin.
Can we get any example where current location is triggered by a button. Also is it possible to get the search box populated with the current location?
Thanks
FD
Hi Bjorn,
thanks for the nice store locator.
I’m just playing around with the json feature and the db-query for a large amount of addresses. The solution for searching in a radius that you postet is a little bit inexact.
I took the solution that is described here: https://developers.google.com/maps/articles/phpsqlsearch_v3
$locations = $db->query(”
SELECT uid, pid, map, categories, title, latitude AS lat, longitude AS lng, address, info_window_content, ( 6371 * acos( cos( radians(“. $origLat .”) ) * cos( radians( latitude ) ) * cos( radians( longitude ) – radians(“. $origLng .”) ) + sin( radians(“. $origLat .”) ) * sin( radians( latitude ) ) ) ) AS distance
FROM tx_gomapsext_domain_model_address
HAVING distance < 25 ORDER BY distance LIMIT 0 ,100;
");
There is also one thing with the maxDistance search. I needed to set a small value for the maxDistance like "5 km", but in line 1426 in jquery.storelocator.js the vars for data.distance and maxDistance are not defined as numbers, so it's only working with distances larger than 10 km / 10 miles.
if ( Number(data.distance) <= Number(maxDistance) ) {
locationset.push( data );
}
/*
if (data.distance <= maxDistance) {
locationset.push( data );
}
*/
Thanks and best regards
Sven
Hi, yes that’s the point of the database query. It returns results for a more general area and the jQuery plugin then does the Haversine formula to further narrow down the locations. It’s done this way so that the database query is fast when querying large tables and the code comes directly out of a “High Performance MySQL” book. The plugin can handle at least 1,000 locations quite well so the database query doesn’t have to return results that are highly accurate.
I will look into the max distance issue.
Thanks
I tested the max distance setting with a value of less than 10 and I’m getting the correct results on my end. Do you have an example I can see?
Hi Bjorn,
At the moment I’m working with about 3.700 locations. I can send you a link to the locations-php-json-file. I can’t explain it, but the result wasn’t really precise without chaning it to the google-database-query-example…
Unfortunately I dont’t have a live example right now, but I found out this issue only exists, when pagination is set to true.
In my case I forgot to unset this setting in my example, and didn’t habve the proper HTML code in my template for the pagination. Sorry, my fault.
When I set pagination to false, I have a different problem with the sorting of the list and the markers.
I changed the sortNumerically function to this, because otherwise it’s sorting like this:
1.1 km
11.44 km
14.13 km
…
2.1 km
20.93 km
…
3.4 km
…
/**
* Location distance sorting function
*
* @param locationsarray {array} locationset array
*/
sortNumerically: function (locationsarray) {
this.writeDebug(‘sortNumerically’,arguments);
locationsarray.sort(function (a, b) {
return (( Number(a.distance) Number(b.distance)) ? 1 : 0));
});
},
Regards
Sven
HI, First of all I want to thank you for this plugin!!! cheers !!!!!!!!
I’am trying to map a raw data which is a json data, where the key values are different, eg: Zipcode, Latitude, Longitude, how can I map this key values
to the plugin…
I’d recommend changing the array keys with the back-end language you’re using before outputting the JSON.
Thanks Bjorn!!!!!!
But what if I can’t do that, because it is not my data? How do you map data that has a `longitude` key to your plugin exception a `lng` key
When setting visibleMarkersList to true, the item in the location list does not highlight upon clicking it. You must click twice before it is highlighted. When removing this parameter, it highlights it upon first click. Is there any way to fix this? Thanks!
I was able to fix this by moving these three lines:
// Focus on the list
$(‘.’ + _this.settings.locationList + ‘ li’).removeClass(‘list-focus’);
$(‘.’ + _this.settings.locationList + ‘ li[data-markerid=’ + markerId + ‘]’).addClass(‘list-focus’);
Below this section of code:
// Custom selected marker override
if (_this.settings.selectedMarkerImg !== null) {
_this.changeSelectedMarker(selectedMarker);
}
This way, the checkVisibleMarkers function which fires when the map is moved happens before the ‘list-focus’ attribute is applied.
Thanks! I will work this in.
Here’s an interesting situation on ‘no results’.
Let’s say I searched for “penn”. The API understood it as “formatted_address:”Pennsylvania, USA”” and the originMarker is placed on the state of Pennsylvania.
But since I don’t have any locations there, I am taken to a marker at lat:0,lng:0, in middle of the ocean and told “No results”.
It would be helpful to have no marker, but instead just have the map zoomed to the originMarker.
Right now I wouldn’t know if my search didn’t work because the map didn’t understand “penn” or because there wasn’t a location.
Hello,
your map is great plugin! But I get some errors:
1. Uncaught TypeError: Cannot read property ‘trim’ of undefined on line 575: if ( $(‘#’ + this.settings.addressID).val().trim() !== ”){
2. If you check/uncheck filter option (for ex. 3-5 times in 3 seconds) you got error “Invalid address”.
How it’s possible to fix this issues?
That trim line was changed in v2.5.0 to support older browsers. Make sure you’re using the latest version of the plugin.
Good morning,
Can someone kindly help me understand this plugin?
Locally the sample plug-in file, do not work! something is missing to implement?
Where do I find the following files 😕 //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css
Thank you very much and have a nice day
I using your awesome plugin, but I am having some trouble. I am trying to assign custom icons to markers. I am producing the json via php.
The json is all correct.
Just for direct testing I have made the following change to the js source code.
// Custom single marker image override
if(this.settings.markerImg !== null) {
markerImg = ”;
if(this.settings.markerDim === null) {
if(typeof cusmarker !== ‘undefined’) {
markerImg = ‘http://www.trekfind.com/wp-content/uploads/2016/03/picnic.png’;
}else{
if(locationData.cusmarker == ”){
markerImg = this.markerImage(this.settings.markerImg, 30, 30);
}else{
markerImg = this.markerImage(locationData.cusmarker, 30, 30);
console.log(locationData.name + ‘ – ‘ + locationData.cusmarker);
}
}
}
else {
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
}
}
cusmarker is the json assigned icon url.
While it does display the icons, they seem to load at random and not according to ID. I searched for a built in way to do this, but the closest I found was the icon by category.
Any help would be greatly appreciated. I was planning on donating, but if you can help me out I will up the size of it.
Thanks,
Jason
Do you have an example that I could see? If you’re setting the image dimensions manually you could take this out of the this.settings.markerDim === null conditional. You can also probably take it out of the this.settings.markerImg !== null conditional.
I can get you a link and access, but the site is in development and I can’t give details publicly. If you are available for any help, feel free to email me.
This is a fantastic plugin, Bjorn. Thank you sincerely for all of your work.
Now the inevitable question: How do I get the auto-geolocated address to appear in the search field and become the new default location for any further filtering or property changes? For example, once the results have loaded, if the user changes a category filter, the map zooms all the way out and centers on all of the filtered locations, rather than just the locations within the initial 10-mile radius. Am I missing a property somewhere?
See: http://www.solarroast.com/locations
Thank you again!
Rob
Hi, so when you click a category the plugin automatically centers and zooms based on the filtered locations (otherwise, there may not be a location with the category selected in view depending on your zoom settings, etc). All the locations should still be within the maximum distance setting if you look at the distances in the location list. The actual map container div isn’t showing the 10 mile radius when you search for a location on initial search, it shows the locations based on the entered address and the zoom level setting. However, note that the max distance isn’t applied initially when using the autoGeocode setting, which is a current limitation but I may address it soon.
Hi again, the issue with max distance not applying with autoGeocode has been addressed in v2.5.3
Thank you so much for this! It’s exactly what I’ve been looking for. I have one question. Is it possible to call the map twice? I’m trying to show the map in a tab the user can open on mobile (but not on desktop). To achieve this, I was calling the map twice and hiding it once on mobile (and vice versa for desktop). Is it a Google thing that keeps the map from appearing a second time? Sorry, I’m a complete novice when it comes to store locators (which is why I’m so glad to have found your plugin – thanks!).
Hi Bjorn,
First, i just want to say you’re amazing and you have made life easier to build a store locator . And Yes, Am using your plugin and the client wanted something from me on my current project for them . And the request is :
When one goes to the store locator , (click from the Menu Option to select the storelocator) , The Browser request to use the location of the USER . if i say NO, my MAP DIV is empty . The client whats a way i can set a default location to an Address and the Map is always showing . That’s the first question .
Secondly, when the Marker OR one of the Marker is clicked on the map , the client wants the location of the clicked marker to Scroll to the top of the LIST RESULT on the LEFT SIDE . (Just like when you click any one of the left side locations and it automatically scrolls to the top ) .
Lastly, Is there a way the default locations can be showing without the LIST RESULT on the LEFT SIDE, showing on first load of the Storelocator page . Maybe after i have successfully set the default to “TORONTO” . Then the result list doesn’t load except i type on the input text. They want Only the STORE LOCATOR Picture ontop showing with the default map location on the first load .
This is the project below .
http://ozery.gouat.com/store-locator/
Thank you for you help Bjorn .
This is COMPLETED . i have find it out myself . Thanks for the plugin BJORN.
Hi Bjorn,
Thanks for created this amazing jquery plugin. I have one question about this.
The location list now sort by distance (between the defaultLoc).
The plugin required to setting defaultLoc or using autoGEO to show the location list/map.
I have a set of location data generated by JSON. Are there any methods to make the location list sort by JSON data? (Just follow the sort order with JSON data – same sorting)
Thank you for you help.
If you’re open to modifying the plugin you can comment out the sortNumerically conditional statement. Search for the comment: “Sort the multi-dimensional array by distance” – it should be around line 2050
Hello Bjorn… I cant get the map to appear in the map container. I’ve tried everything I can think of.
http://www.realestatefinance.com/banklocator/dist/index.html
Lots of errors on the test… http://www.realestatefinance.com/banklocator/test/storeLocator.html
the google example version works fine…
http://www.realestatefinance.com/banklocator/phpsqlsearch_map.html
Happy to send a donation.
I wonder if deleting the space after “‘querystringParams'” (before the colon) would help. I’m an amateur but I took a look and that was the only potential discrepancy I saw.
I’m not sure I understand what you’re trying to accomplish. Can you just use the “bh-sl-map-container” that’s included in the example files? The test directory is for unit testing in development and is absolutely not intended to be placed on a production server. dist/ = public files that would be uploaded.
When i do initial search it works but when i change the mileage after a successful search it does not search unless i change the address.
Right, that’s how it currently works.
Hello Bjorn, nice work.
How can I set up the default system filtered by category or country with parameters?
Regards
Hi, Bjorn,
Thanks so much for you plugin.
I have a question regarding data files for markers. Is it possible instead of latitude and longitude they use zip code for geolocation.
I have a lot of data without lat/lon information but with zip code only.
Sorry, no that’s not going to work with this plugin. You need to have your locations geocoded and I’d highly recommend it for the best accuracy and to avoid unnecessary lookups/API calls. There are several services available for bulk geocoding.
Love the project!
First it didn’t work because of missing API key, but that whas a quick fix.
I want to know if the list could also be wilt numbers instead of letters (like the A B C list).
Thanks,
Bero
Hi,
Please tell us how you fixed this missing API key thing? We get the same error.
Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
Thanks in advance.
Regards,
Bart
The API key warning is not an error, it’s a warning and a key is not required unless you’re hitting the maximum request limits. If you want to use a key you just signup https://developers.google.com/maps/signup and put it on the end of the maps URL script.
Hey, after i checked using library=places, and using autocompletion needs to have an API. Otherwise the autocompletion return from the Gmap API returns an error saying no API key is defined.
Nevertheless for the geocoding and showing map only a warning is shown and you can still display your results without issues. But now i’m wondering the autocompletion seems to use a lot of queries, what’s the solution here to avoid hitting the max request limits ?
Still looking for a solution to displaying number and not letters in both the List and Markers. I found one solution in the comments, changing the letter in “String.fromCharCode(‘A’.charCodeAt(0) + (storeStart + y))” to a number, but paging breaks that after you leave the first page the numbers on the markers increase but the numbers in the list start over at 1. Also after the number 9 it starts using special characters in the markers.
Why are you replying to this old non-related comment? See the disableAlphaMarkers setting – all plugin settings are documented.
That only works with the list. The map markers are still using letters.
No, the markers on the map will be the default Google markers with no label if you use disableAlphaMarkers. You should use the callbackCreateMarker if you want to override the marker labels.
What I ended up doing was this:
//letter = String.fromCharCode(‘A’.charCodeAt(0) + (storeStart + y));
letter = (y + 1).toString();
in the loop where you add the markers and infowidow. it’s around line 2914
Whooop, great plugin, just a question, theres no examples using callback, for example i want to grab the store ID of a selected store finder store, im using modal so went for the callbackModalClose function but im not sure where if anywhere the selected store information is kept.
Hi Bjorn,
how to urlencode variables such as : {{origin}} {{address}} {{address2}} {{postal}} {{city}} ?
At assets\js\plugins\storeLocator\templates\location-list-description.html I have URL
which does not work well in IE, if polish language and characters are used.
Try using “triple-stash” or three brackets around the variable: http://handlebarsjs.com/#html-escaping
I loved his work, as I add a question to zoom to click a point location
hiya, I have been having a problem? with the locator, i try to give it a default location but it keeps showing Rumania instead of Mexico: http://www.invisalign.hunt.com.mx/encuentre-un-doctor/ even i try to change it directly on the js but it keeps showing the same, sometimes when i refresh it a lot i can see Mexico but then it goes back to Rumania, I have tried it all
Automatic location detection failed?
My own website and your example : http://bjornblog.com/storelocator/v2/autogeocode-example.html
Both return the dialog popup:
bjornblog.com says:
Automatic location detection failed. Please fill in your address or zip code.
Any ideas how to fix? It no longer works on Chrome or Safari (Mac OSX 10.11.4)
Yes, starting with Chrome 50, the browser no longer supports using the HTML5 Geolocation API on non-secure connections. These warnings are displayed in the console if you have it open. You’ll want to purchase an SSL certificate in order to for this feature to work. I updated the example page so that jQuery and Google Maps are loaded over https and you’ll see that it is working:
https://bjornblog.com/storelocator/v2/autogeocode-example.html
Information about the browser change is here:
https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only?hl=en
“storeLocator is not a function when using with require.js”
If I include all the required js files inline the plugin works fine. If I include them using require.js the function is returned null. “storeLocator is not a function”. Any thoughts on how to solve this? Everything is loaded in network resources…
I haven’t used require.js but I’ll try to get that figured out.
I’m trying to figure out how to select multiple categories and list ALL of those results instead of just the ones that share BOTH categories. For instance, if selecting “coffee house” and “bar”, instead of just listing the locations that are a “coffee house” AND a “bar”, I’d like to list ALL of the “coffee house” results as well as ALL of the “bar” results all together.
If this has already been answered my apologies. I searched but maybe I searched for it the wrong way.
Bobby
exclusiveFiltering setting.
Hi Bjorn, i love tour plugin, but how do i automatically search with the users current latitude and longitude instead of the user submitting the form?
thank you
autoGeocode or geocodeID setting.
I’m having a huge issue. When I select certain categories during my search, and then deselect them my map goes completely blank.
http://gacapus.com/r/directory/capus-resource-directory.html
Bobby
Hey! I just downloaded your plug in, but I can’t even get the demos to work. I tried adding an API key, and using both Chrome and Firefox, Chrome incognito and Firefox private browsing, and well the map doesn’t work! The demos are supposed to work as downloaded, correct? I entered the zip code 55105 and selected search and nothing happens.
The plugin needs to be run on a local or remote web server. They will not work if you just open the html files in a browser after downloading.
As an addendum to my previous comment: The demos in production, but not locally.
Just wondering of this support board is still being utilized…
http://gacapus.com/r/directory/capus-resource-directory.html
When I turn on pagination my page shows ALL of the numbers in the pagination… I have thousands of entries so it shows 242 numbers… (1, 2, 3, 4, 5, 6, … all the way to 242). Is there a way to make this look normal: “1, 2, 3, … 200” or “Showing 1-26 of 200”?
Also, my searches show ALL of my locations instead of what I searched for?
How do I show numbers in my search results list and on the map instead of letters?
Lastly, when I select categories and then de-select them sometimes the map goes blank.
If anyone can help me it would be much appreciated.
Bobby
I can answer showing numbers on the map markers. A quick edit to the _defineLocationData function will do the trick.
1. Declare the variable numMarkerImg
2. in the if block under the comment //Use dot markers instead of alpha if there are more than 26 locations:
if (this.settings.storeLimit === -1 || this.settings.storeLimit > 26) {
numMarkerImg = {
url: ‘https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=’ + (markerId + 1) + ‘&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48’
};
indicator = markerId + 1;
marker.icon = numMarkerImg
}
There may be an easier way, but this works swimmingly for me.
Hey there… I m suddenly having issues on my client’s site just on mobile. It is throwing the “Could not load plugin templates” error. I set it up using json. Any suggestions for a fix on this?
If it’s mobile Safari it’s a known issue and I haven’t been able to track it down and/or replicate the problem. The easiest way around it is to use inline Handlebars templates with the listTemplateID and infowindowTemplateID settings. The second box under Getting Started on the Handlebars site shows an example of what the code looks like.
I’ve copied your example exactly..
On your example –> https://bjornblog.com/storelocator/v2/ , I have no problems with searches by address, or zip codes. if it’s too far away it’ll say it’s over 60 miles..
but on my example –> http://jit.newagemadden.com/locations , I have a slew of problems.. unable to find address on basic zip codes, basic cities..
What am i doing wrong??
It’s likely because of the new API key requirement. I’ve updated the documentation above with instructions on obtaining a Google Maps API key and enabling the appropriate servers. This changed as of June 22, 2016.
Bjorn, thank you for this awesome tutorial and your amazing files, you’re the greatest. I have messed something up somewhere and I’m hoping you can help. The URL where I placed your code is http://www.extractcraft.com/store-locations. A few things:
1. I’m using a SquareSpace site, which won’t let me access FTP, so I’m having to host the custom files (except index.html) on another site.
2. I can’t seem to click in the Address/Zip Code box to input a query.
3. I’m getting an error that says “[Warning] jQuery.Deferred exception: $(‘#bh-sl-map-container’).storeLocator is not a function. (In ‘$(‘#bh-sl-map-container’).storeLocator()’, ‘$(‘#bh-sl-map-container’).storeLocator’ is undefined) (2) (jquery-3.0.0.min.js, line 2)”
If there is any way you can help me, I know I’m just overlooking something stupid, but my brain can’t wrap around what it is. Thanks!
Alright, good news, I figured out point 2, it was a problem with SquareSpace CSS. Still getting the bh-sl-map-container error, so if you don’t mind taking a look when you get a chance, you would be my hero!
Hello, it looks like 2 versions of jQuery are being loaded on that page – version 3 right above the store locator plugin include and then v1.11.1 at the very bottom of the page. This is probably what is causing the problem.
Nevermind. I figured out the key error. But, I’m still having a problem. While the map does display with all my locations, no matter what zip code I put in I get an error message saying that the zip can’t be found.
http://www.kool-pak.com/2016/scr/locator/dist/locator.php
Again… nevermind. I pounded away at it and figured out that I needed to enable more API’s. Working fine now. Sorry for the spurious questions.
Yeah, this is a new requirement as of late last month. Google recently changed their policy on API keys http://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html
I’ll be updating the documentation but if you’re wondering why it’s not working you’ll want to generate an API key for your project at https://developers.google.com/maps/documentation/javascript/get-api-key
You also need to enable Google Maps Geocoding API and depending on the options you are using the Google Maps Directions API and Google Places API Web Service.
Hi Bjorn,
Thanks for the reply and the fantastic plug-in. It’s really great. Yes, I did figure out how to generate the key and enable the different features. I do have one minor problem that I haven’t been able to solve yet… I can’t get driving directions from the US to locations in Canada. I’m assuming it’s some sort of regional designation that I have to enable or apply, or something in the XML I’m generating, but I can’t figure out how. Any ideas?
Thanks again.
Mark
P.S. I’ve sort of solved the directions issue by enabling inline directions, which does then display directions to locations in Canada. But it should also work if I wanted to open up a separate browser tab, right?
I’m using this plugin without the form cause I need to handle location selection with cascading dropdowns (this is a design requirement). How can I trigger search without bypassing processForm?
Hey great plugin. Is there a way of making the map center on the marker that’s been clicked? Thanks
Hi ,
This is simply awesome , but i have a quick question probably this got resolved before or some one might have asked this already :
Can i have the functionality running through tomcat or converting this grunt project to web project in java ? I am sorry if its becoming hard and i am just trying to understand the running of this functionality through jsps and deploying on a web container where it has to provide the same fucntionality ?
Thanks,
Akhil.
I have been usingthe plugin for a while and works wonders but now Im facing a big problem, I need to do a search by name (name of the person, or bussiness) and I use special characters in a lot of names (accents – spanish) but when i do the search i have to type on the right word ‘núñez’ if not im not getting the result. I want to be able to type ‘nuñez’ and get all the restults as if i was typing ‘núñez’. Thanks a lot
[continuation] I have this for the name search,
Buscar ::
It’s supposed to search the name of the doctor… as for the jquery I change nothing because I didnt want to mess up with the plugin
Hi Bjorn,
Have you any tips on how I might use your plugin in a WordPress site? I have tried following the steps shown here http://jdmweb.com/how-to-turn-any-jquery-plugin-into-a-wordpress-one; however, I’m not clear as to how I name paths (in my init.php file) to the CSS files, nor paths to the javascript files.
Incidentally, in my init.php file, I had certainly given you credit as the author and had included a link to your blog. As it stands, I’ve not gotten the plugin to work in my WordPress site. I would very much like to do so, mind you.
Thanks in advance for any help you may offer.
Kind regards,
Bruce
Hi Bruce,
I have a WordPress version of the plugin available for sale at https://cardinalwp.com/
Hi Bjorn,
I was wondering if I could somehow get the lat and long variables when I press my “Autogeolocate” button (I have one on my form that enables geolocation). Could you give me any hints?
And thanks for your great plugin!
If you’re using a back-end language to generate the location data the latitude and longitude are sent over with the AJAX request via the HTTP GET method as origLat and origLng along with some other things. Otherwise, the callbackBeforeSend callback also has the coordinates available.
Thanks. I will dig into that. Again, great work.
How do I recode the pagination to read “Page 1 of 8” instead of “1 2 3 4 5 6 7 8”?
Bobby
It’s not built in at the moment. Make sure you’re using the latest version of the plugin so that total pagination number is set with the storeLimit setting and not the total number of locations. If you want to make a custom modification the pagination is set up in the paginationOutput method around line 831.
When I apply this to an “https” secured portion of the site the google map stops showing and the list results do not show up.
Bobby
All the example links above use https. Check to make sure the Google Maps url is set to https, etc.
Hi Bjorn.
Thanks so much for this plugin. Googles Map API has been giving my a headache for the last week.
Have a great day.
– Matt
Quick question, is it possible to have the first result (A) be pre-selected by default if you enter the map through a query?
For example, if I know the address of the location I’m looking for, and the URL query already has it, it would be great to have the map load with the match automatically, and have the info-window popped-up.
Thanks
There’s nothing built in to do this right now. If wanted to make a modification it’s just a matter of using the infowindow.open Google Maps API method. Around line 2317 you could check the count of the loop and send an extra boolean parameter to the createInfowindow method and open the infowindow in that method if the parameter is true.
Hi Im trying to this but im struggling, could you tell me the code i need please.
thanks.
I want to know if i am loading dataLocation,taxonomyFilters and i am also using search.
so when i search with zip after that i want to reset map and load all the locations.
i puted reset button after submit button also.
Sorry we move it on http://mapa2.byethost7.com/
I have a question.
I love your plugin Bjorn, but I am having trouble getting it to work with my site because I have a results page with multiple links to produce maps. Can you give me some pointers on how best to launch the maps from one of many links or buttons on a page?
Thanks!
Rob Gravelle
Please see the query string example.
autoGeocode doesn’t works on chrome (it map).
do i have to upgrade this script?
You need an SSL certificate:
https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only?hl=en
Hi Bjorn,
Fantastic plugin! I noticed the date on it and thought there’d be no hope of getting support on it, but looks like you’re still actively replying, so hoping to get some clarification on an issue I’m experiencing.
Is there a limit on the number of markers that can be imported from XML (whether from Google requiring an API key or the plugin not handling a large number)? I’ve got an XML file with around 120 entries which loads fine, but as soon as I attempt to load an XML file with ~400 entries, the entire div disappears including all of the search and filtering features that I’ve added in.
Below is an example of the marker format I’m using. The format of the markers hasn’t changed between files, so I feel like I’m running up against some kind of limit.
Any ideas/tips/thoughts? I feel like JSON is overkill for ~400 entries, so I’m hoping very much to avoid it if possible.
Never mind, I just discovered what the issue was. There was a marker with a double quotation mark in the address which was breaking the XML format 🙂
Thanks again for a fantastic plugin!
First, thank you for writing the plugin. It works very well. My only question is why my phone numbers are not “click to call” on mobile devices. Site is tireservicesolutions.com. I’ve tried a couple of different formats in the .xml table and they still are not clickable. Is there anything I can do to fix this? Thank you.
Hi Bjorn, this is a cool plugin! Thank’s for your job!
But a question about filtering by categories (https://bjornblog.com/storelocator/v2/categories-example.html): now if you select a few categories (1-3) you will see ‘No results’. If you add Bars category to Restaurants you will see just 3 bars without restaurants (for Edina location). I think it worked a few days ago and may be the problem in google API?
Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
util.js:208
Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required.
I am getting this error how to fix this
Like the error says you need a Google Maps API key. Please see step 4 above.
Hi Bjorn.
Thanks so much for this plugin. can you tell me please how to set custom map styles?
Thank you in advance.
Solution found thank you.
Thank you for the fantastic plugin.
Is there a way to add in category search filters like this https://www.chloe.com/experience/en/boutiques/ (click on the hamburger in the input box to reveal the Continent / Country / City dropdown)
Basically a way to pull each location’s Country / State / City from the XML locations list, then have the dropdowns automatically populate as they are selected? For example if one select United States as the country, cities from other countries should not appear in the cities dropdown below, etc.
Hi Bjorn, fantastic plugin by the way… Thank you for providing this for the whole world to see!!
Is there anyway that this plugin can read from more then one xml file, and pass variables (from more then one xml) from the main.js file to the location list and the infowindow pages?
Thank you for your time and effort you have put into this fantastic plugin
Hi Bjorn, love your work.
I’m looking for a way to disable info window without tempering with the plugin code. Would love to have that option in init. Hope you’ll consider implementing this in the future.
does the key need to be added anywhere else than on the html file? I’m getting MissingKeyMapError in console even after adding the
Also.. I need to change the path of the location of the plugin templates. Can you please explain where can this be hardcoded?
I tried changing the lines 81 to 84 of jquery.storelocator.js with the exact location (https://www…) of the template files on my server and it didn’t work.
infowindowTemplatePath
listTemplatePath
KMLinfowindowTemplatePath
KMLlistTemplatePath
Found the problem. I was able to figure out how to load the files from a specific location, now the map loads but the bh-sl-loc-list is empty! I guess I’m missing a link somewhere for the handlebars js to properly populate the list with all locations?
Dear Bjorn,
Can I use this in India ? I need to change any settings etc., If possible let me know.
Hey Bjorn,
Thanks for this plugin. Two things for you.
1) When grabbing the latest version of storelocator.jquery.js from Github, it appears to be missing a global declaration of the “region” variable. At least, this is what my browser (Chrome) threw an error on when submitting a zip code. Easy enough to fix on my end, but I thought I would let you know.
2) I am using XML data and filtering by category. I am also using pagination. This behavior appears when used in conjunction:
Map loads with results, displaying ten results at a time. I have 27 in total currently. Only the first 6 or 7 location items have a category. Category filtering works as expected when the map first loads. If I navigate to the second page of locations, then click on a filter, the map empties out, centers in the middle of the ocean, and the pagination div displays PREV and 1. Clicking on either correctly loads the results and re-centers the maps on available locations. There may be something I’m missing that makes this an easy fix, but I’m hoping you can shed some light on this for me. Thank you!
(I’d be happy to send you a private link to the code, but prefer not to post it here)
Would there be a way to have the querystringParams and fullMapStart and originMarker and storeLimit:-1, where I can load a map on page load using the query string, but have the map zoom in to the origin marker?
For example, I got to: http://www.site.com?bh-sl-address=miami and the page loads with all locations across the country, but zoomed into miami (with origin marker) by default.
I am having a few issues with this plugin and it returning the correct results that are stored in the XML file. I’m not 100% sure, but I think it is down to the client storing addresses that are across the world. The addresses in the USA and UK seem to work ok, but in other countries the addresses don’t get picked up? I can’t be certain of this though because if I search some addreses that are based in USA, they don’t show up either. It feels very much like Russian Roulette with what results show up at the minute.
Has anyone else experienced this issue, if so is there a known fix for it? Keen to get this sorted as the client is hot on my heels with it.
Hi, thanks for the great plugin,
just wondering if you know of a simple way to have a small group of selected locations above the store locator (outside of the regular loc-list) which can be clicked and will move to the location on the map, maybe this could be linked via a matching data-markerid=”1″ attribute ?? if there is a way to do this by triggering the corresponding markerid like in listClick function ?
Thanks!
CHRIS
Hi, what if my xml dont have lat long only address, possible to convert address to long lat? Thanks
Hi, How can I make this work if xml data looks like old school?
Chipotle Minneapolis
44.947464
-93.320826
Restaurant
…
Found a bug? i think on https://www.bjornblog.com/storelocator/v2/namesearch-example.html example. If you search by zip it will show the results no problem, but after you clear zip input and then search by name it doesnt show any results.
HI there,
Great plugin. I have a little problem. I have been using the plugin for a while now but it seems like the state of INDIANA is not properly marked. The Marker is in the wrong state. If you type the address is works but if you use the drop down, it won’t bring the proper locations as it thinks INDIANA is somewhere else. The green marker is in the wrong location. I have tried for a few hours to fix it myself and I have ready pretty much everything in the log/updates and I cannot figure out. Can you please help me? This bug is only with the INDIANA state within the drop down.
URL: http://lumenwerx.com/en/agent-locator/
Any suggestion would be great!
Thank you!
P.
Good evening. My company is interested in this product. I’m a web developer and the default version is really close to what I need. The problem is that I need to understand how to add some locations stored in a json file. Probably I need a sort of walkthrough or at least if it’s possible because the client that we’re working for send us a csv file that I manually switch in a json file. So could you give me more information about that? Are you reachable by emai? Thank you in advance and I wish you a good day
Hello Bjorn,
Thank you for this beautiful plugin.
I am using this plugin for website https://www.lisatoddnow.com/pages/retailers It was working fine before but unfortunately it is not working now.
You can try any of these zipcodes: 92625, 90025, 92660, 90291
Can you please let me know issue?
Thanks in advance!
SD