jQuery Store Locator Plugin
Warning: Invalid argument supplied for foreach() in /home/customer/www/bjornblog.com/public_html/wp-content/plugins/gravityforms/form_display.php on line 1726
Warning: Invalid argument supplied for foreach() in /home/customer/www/bjornblog.com/public_html/wp-content/plugins/gravityforms/form_display.php on line 473
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.
Hi, i have a question..
First of all GREAT plugin!
i will show over 500 shops on the map, with custom icons.
i changed this code:
rule: 756: if(settings.storeLimit === -1 || settings.storeLimit > 26){ // changed 26 to 2000..
and after that i changed:
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));
//END ORIGINAL CODE
//Set up pin icon with the Google Charts API for all of our markers
//CUSTOM CODE
var custompinImage =new google.maps.MarkerImage(‘http://www.mylocation/images/’ + locationData[‘storetype’] + ‘.png’,
null,
new google.maps.Point(0,0),
new google.maps.Point(10, 34));
Problem is: The custom icons are working, but the first/closest store has no icon on the map. all other stores are showing up.
I hope you can help.
thnx,
Remco
Great plugin. Really awesome work, thank you so much!
Does anyone know how I can include the “Zoom here” and “Street view” links shown on other maps?
Do you have an example of using data directly from an array instead of using a file? I need to be able to change the list of locations which are dependent on other variables.
I need help to push results to another page
thanks
Hi Bjorn – fantastic plugin.
Just wondering if you can suggested the best way to include a radius circle for each marker. Maybe including the radius data in the xml file so that it can vary for each marker.
Thanks in advance!
Hi, does anyone know how to have different coloured pins when pulling from a database using JSON? For example, if I had a database table called type, with red or blue in it, the correct coloured pin would be displayed on the map using the colour override function? Any help would be really appreciated. I’ve seen a solution above using XML but struggling to get it to work with a database. Thanks 🙂
Hi!
how can I to stand out a marker (for example changing the icon)? My featured location already works, but I would like to see it standed out in the list and in the map.
I load 99 places in my map.
And what about stand out the marker on the list? Is it posible?
Thank you
Hi Bjorn, First of i was glad to know there is a plugin very close to what i am looking at. However there is one issue i am facing and stuck up very badly.
1. I have a Spring MVC Mongo DB application which uses Thymeleaf templating engine. I need an autocomplete google geolocation filed which i can integrate into your existing plain address text field. So that the user is given the choice to pick the address he wants to either store into DB or search on.
2. Here is the Web folder structure integrated with your templates/js/css/json files. However i don’t get the map shown onto any browser i am testing (IE8.0, Firefox 25.0.1 and Chrome 31.0).
Webapp
resources (copied jQuery-Store-Locator-Plugin contents into below folders respectively)
css
js
vendor
templates
json
Web-Inf
templates (thymeleaf templates)
site (my app pages *.html mapped to thymeleaf template in Spring configuration)
search.html (code from json-example.html)
Note: All the resources under Webapp folder are accessed in Web-Inf .html files as (../../../resources//*.)
Using this structure in Webapp and “jQuery-Store-Locator-Plugin” integrated i don’t see the map loading.
3. Also i would like to replace the usage of locations.json in the json-example.html file to get the JSON response from Spring Controller. For which i have a service returning JSON array from MongoDB.
[{“id”:”5298d75ed69bf01a226dbc63″,”edumpId”:null,”lat”:”17.385044″,”lng”:”78.486671″,”address”:null,”address2″:null,”city”:null,”state”:null,”country”:null,”postalCode”:null,”assetCount”:0},{“id”:”5298e55ad69bfb0d77c9644f”,”edumpId”:null,”lat”:”12.9715987″,”lng”:”77.5945627″,”address”:null,”address2″:”Bangalore Urban”,”city”:”Bangalore”,”state”:”Karnataka”,”country”:”India”,”postalCode”:null,”assetCount”:0}]
It would be real great if you could help me with above 3 issues i am facing now.
regards,
Sai.
Sai, did you ever get that 3rd part to work? I’m trying to do the exact same thing, with the json array wrote into a variable on the page on the backend. I can’t get it to work, even with rawdata attribute. Would love to know your solution if you got it working. Thanks mate!
Hi
how can i set the origin location to be same the user location?
I mean. Distance calculation is based on the location of the user…
hi sir Bjorn, how can i use this w/o searching required before to appeare the map?
Change fullMapStart to true: Set to true if you want to immediately show a map of all locations. The map will center and zoom automatically.
Hi Bjorn, did you happen to work with a responsive google map design? It would be real helpful if you could provide some pointers on how to make the existing sample a responsive one.
regards,
Sai.
Well, it seems like Bjorn has gotten too busy to offer support for this amazing plugin 🙁 Unless, I’m missing something and there’s a new place to ask questions.
Anyhow, I’ve seen people with the same problem and I wanted to inquire if ANYONE has figured out the appropriate way to do this. I am using this plugin for a major corporation that has store locations all over the world. I’m basically creating a single-page site for each country, which will display all of their locations within each specific country. However, with the various ways countries use addressing, as well as cities having similar names, sometimes locations will pop up in a completely different country.
What is the correct way to search and display locations SPECIFIC TO ONE COUNTRY? I need to create these single-page sites with this plugin for countries like Chile, Brazil, Japan, England, Canada, Mexico, etc.
Any help would be greatly appreciated! Thank you!
Actually, I think I see how this is done. For those wondering the same, just add “region” to the script. So if you were wanting to get search results specific to Chile, you would have…. script src=”http://maps.google.com/maps/api/js?sensor=false®ion=CL”
You can find the country code top-level domain here:
http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains
Hope that helps anyone else!
Oh, and I had one other small issue. Whenever I submit a location to search, how do you get the pin to show that location on the map with the results put in through the XML file?
You can use the originMarker option to mark the origin.
Hi, thanks for this awesome plugin.
I have managed to integrate this into prestahop store for a client, ( http://www.no-match.co.uk/stores ) however I have gone the xml way.
I would like to pull the address details from the prestashop database.
Can this be done live, as it is requested, or do I have to extract the data to a file, then use that file ?
Live would be the best way.
Has anybody done anything like this, and if so, any instructions for doing so.
Thanks
Anyone have a solution to limiting the auto-geocoded results to the max distance.
I am currently using the featured store element, in which featured stores show up on the top of the list. I am also using max distance selector, for when a user searches by zip code. However, with auto-geocoding on, the first results show all featured stores regardless of distance.
We have over 1,000 stores on our locator, and at least 30-40+ are featured. It is a bit weird to have those top 40 show on auto-geocode, when some are in Japan or Korea, etc… Really need the auto-geocode to only show featured results within max distance.
Thanks!
Hi!
Great script! Thanks a lot! I have the problem, that I’m not able to use a custom pin icon for the entries. Many to read about, but no solution for me. So, can you give me a hint?
Is it possible to hAve a full map, but to limit the list or maybei hide it?
Hi Bjorn,
I’m a novice in coding but through struggling i managed to make the plugin work partially.
The things that don’t work are:
The list side bar doesn’t show
When I’m editing my store locations in the XML file the map stays blank.
Could you or anyone in this feed help me out here?!
URL: http://test-nieuwe-template.webshopapp.com/verkooppunten/
Thanks in advance!
Hey CJ,
Thanks for the donation. I tried going to the link above and the location list seems to be loading for me. Were you able to fix your issue? If you’re using XML be sure to run it through a validator – one XML error can break everything. http://validator.w3.org/
Also, I noticed a couple of stylesheets and an image on the site aren’t loading:
/test-nieuwe-template/map-style.css
/test-nieuwe-template/custom.css?1
/test-nieuwe-template/background.png
Thx for the reply Bjorn,
I got the list working and yest I forgot to upload the map-style.css file.
Is it possible to make some stores “preferred” I read something above but I can’t make it work.
I set the value to “true” in the XML file but I can’t see it appear.
When a store is “preferred” will it show first above the rest? Does it work this way?
Never mind my last comment.
I do have one other question:
how do I add an additional image to a preferred partner, like a star image in the list?
rgds,
CJ
You’d want to add that in the list template (/templates/template-list-description.html) and just use the Handlebars syntax. If you’re using the built-in “featured” attribute you can do something like this:
not quite sure what you mean.
I added your line to “location-list-description.html” and in “jquery-storelocator.js” I set “‘featuredLocations’: true”
Is this what you mean?
By the way, I’m trying to implement my test template to http://www.moesengriet.nl/nl/verkooppunten/ but it won’t show the map and description list.
I followed all the steps just like it did in test (http://test-nieuwe-template.webshopapp.com/verkooppunten/)
Am I missing something?
Something is not right there. It shouldn’t refresh the page like that. The featured locations looks right. I am getting an error with the jcarousel on that page. Not sure if it’s related or not but that should probably be fixed to make sure: TypeError: $(…).jcarousel is not a function
Ahh right I solved this one!
The store locator is working for all browsers now except for FireFox. Which is strange don’t you think?
I cannot pin point the problem here do you have any idea what is going wrong here?
Hey CJ, I’m also having an issue getting the list sidebar to show. How did you fix your problem?
Hi Bjorn,
Im tryng to ad an event inside one of the “li”‘s.
I’ve added contact inside: location-list-description.html
And then:
jQuery(“map-container”).on(“click”, “.contact”, function(){
e.stopPropagation();
alert(“Child link click function called.”);
});
But for some reason it doesn’t work..
Do you have any ideas? What i want is to have a link that does a fadeIn of a div on click.
Thanks in advance.
Are you using the map-container div? In the code you posted above there isn’t a “#” before map-container.
Hi Bjorn,
Really nice plug in. Is there a way to trigger the “reset()” function from my code please. I want to do something like:
$(“#map-container”).storelocator.reset();
Is this possible?
I got it… just call the sotreLocator again and it resets the selections on the map… Thanks!
Hi All
Is there anyway to set a default country? All my stores are in Australia, but if I search for Hamilton for example, it takes me to Hamilton in the US
Thanks
I would try region targeting as described in step 4 in the documentation above.
Thanks – missed that bit. Great plugin. You’ve done an amazing job
Hey Bjorn
First i want to thank you for creating this plugin. I really needed it badly.
I’ve a question:
Suppose i’ve some tens of thousands of Listings and some don’t have exact lat/lng values. How can I get the map to work with just only address ,city,state postal ?
I tried a few listings in xml file and map stops working if lat/lng are missing.
Ok i think i found a solution. I think i will code a script that will do geocoding of addresses when a user submits a listing to the database.
Then i will retrieve the Listing and your map will work as perfect!
However can ya suggest if I should use Bing API or Google Geocode API for this purpose and which one is accurate . I know Google has a limit /24 hrs and another limit/hr.
Thanks!
For your existing locations I’d look into bulk geocoding services such as batchgeo (not free), gpsvisualizer (free but you might have to repeat the process a few times to get everything and you need to use the Bing geocoding option to do a lot of locations), or maybe geocod.io (not free) if you’re in the US.
For new locations or location updates, your thoughts look right. I believe the Google limits are 2,500/day and 1/second, so it depends on how often you think it will be happening. I think they are both pretty accurate, it really just comes down to the limits. It looks like Bing’s limit is 30,000/day.
I have another question regarding changing the Variable names.
I am using your plugin on a WP site with custom post types and some custom fields. I am able to get the json file as required , but the variable names are diff.
a chunk of my json file is below:
`{
“id”: 733,
“url”: “http://sitename.com/listing/rk-flower-shop/”,
“title”: “RK Flower Shop”,
“custom_fields”: {
“city”: [
“La Habra”
],
“street”: [
“1403 E Lambert Rd”
],
“state”: [
“CA ”
],
“zip”: [
“90631”
]
}
`
My site is still in the beginning and i can change custom field names/slugs to match the variables used in js file , but what about the Title and url etc…
Looking fwd for some guidance/help.
Hi Bjorn, I had asked earlier about resetting the map and kind of answered my own question. Unfortunately what I was doing was not the correct outcome I am looking for. I color code the pins that I drop on the map, and so resetting the map without reloading the data causes all pins to reset to default color. So the question is: how do I reset the map center and close / unselect any locations without reloading the data? Thanks for a wonderful plugin!
If you want to edit the actual plugin file you can do something like this inside the main mapping function, which takes advantage of the exiting orig_lat and orig_lng variables (origin latitude and longitude):
Center on the origin:
Removing the list-focus class should remove the focus from the list:
And then I think you can do this to close the infowindow:
Hi Bjorn,
Thanks for the reply. I need to be able to issue the “reset” command from outside the plug in though. From your suggestions I can only removeClass on list-focus from outside. How do I do create a reset function in the main plug in that I can call externally (something like $(“#map”).storeLocator({ “reset” }) )without reloading the data and losing the pin color coding. Calling $(“#map”).storeLocator() re-centers the map and closes the infowindow but it also resets the pin colors. THANKS!
Here, you can add a custom callback if you want. In the main plugin js file where the default settings are defined, add the following say after line 56:
After the map variable is defined, add the following callback function after line 650:
Then you can do the rest outside of the plugin file where you set your custom settings. As an example, the main index.html file that comes bundled with the plugin as a demo could be changed to the following (“reset-link” is a class I added to a reset link button test on the 5th line):
You ROCK man! I will give this a try.
Hi Bjorn, I am sorry if this is a silly question but I am struggling to convert your good instructions into a function I can call (eg:
function resetMap() {
var originLatLng = new google.maps.LatLng(orig_lat, orig_lng);
map.panTo(originLatLng); //Center the map
$(‘#loc-list li’).removeClass(‘list-focus’); //Remove list focus
infowindow.close(); //Close infowindow
};
How do I do this with the CallBack as a function I can call from anywhere / anytime such as:
resetMap();
Many thanks!!!!
Or easier still. how do I close the infowindow as an external call? I have created the following external reset routine without modifying the plug in:
function resetMap() {
jQuery(“#list li”).removeClass(“list-focus”);
var container = jQuery(‘#loc-list’),scrollTo = jQuery(‘#loc-list li[data-markerid=0]’);
jQuery(‘#loc-list’).animate({
scrollTop: scrollTo.offset().top – container.offset().top + container.scrollTop()
});
});
PS: Sorry I also need to center map… Thanks!
OK so I got it finally (forgive me as I am very new to this). I am calling the map like this:
jQuery(‘#map-container’).storeLocator({‘dataType’: ‘json’, ‘dataLocation’: map_data_url.
callbackReset: function(orig_lat, orig_lng, map, infowindow){
var originLatLng = new google.maps.LatLng(orig_lat, orig_lng);
map.panTo(originLatLng); //Center the map
$(‘#loc-list li’).removeClass(‘list-focus’); //Remove list focus
infowindow.close(); //Close infowindow
}
});
Then (after adding the code you advised to the plug in) I call the reset like this:
jQuery(‘#map-container’).storeLocator({‘callbackReset’ : true});
But the map loads then blanks out (grey box). The reason for me wanting this reset is I have color coded the pins based on the input data meeting a set of criteria. I want to keep this and reset the map without re-loading data.
Thanks!
Yeah, I’m not sure that’s how you want to call the reset. Are you just using a reset button? Why can’t you just use jQuery’s .on() like I have above?
Hi Bjorn,
I have modified the plug in to color code the pins based on conditions used when pulling data from MySQL. The map is then tied to a D3 graph, so click on a pin, the graph will change. As such, when the graph is selected to “total view” (country view), I want the map to reset to its original loading position, without losing the color of the pins and with infowindow closed and original zoom / position. If I call the map again it does reset it as I want, but I loose the colors on the pins – $(“#container”).storelocator();
So I want to reset the map to initial load (from outside) without loosing pin colors or reloading data (as it is called from server and it takes a few seconds to load). Does this make sense? Thanks!
Wrote a php script which gives me an exact .json format file as used by you in demo. i may come with a few questions, but as i proceed.
thanks guy!
Yeah, that is what I was going to recommend. I’m actually about half-way through a WordPress version of this plugin that will add some additional features and work with custom post types but I’m working on it in my free time and don’t know when I’ll be able to wrap it up yet. I’m probably not going to release that for free though.
Thank you for spending your precious time in reading our comments and replying to them.
WP plugin would be a great thing and surely it mustn’t be free ’cause of the hard work ya putting in.
Well i can say my wishlist/ suggestions like
a) a Post Thumbnail in the sidebar List for each listing/location
b) a review/ratings (stars) in sidebar and also in the info popup
c) allow user to choose pin image from a dashboard / maybe using short code builder etc..
Thanks again!
Thanks, those are some good suggestions.
Hi, thank You for this amazing script. I have a one question, did is posible to scroll loc list with image (small arrow in bottom)? Now, is a standard scroll bar, it’s litte ugly 🙂
Regards, Pawel
That’s just CSS that’s defined in the external stylesheet, so it’s not difficult to change.
Thank You for anserw, i have a last question. I have a 340 position in data base, but i haven’t lat and lng data, it is posible to run script without this ?
No, you need to geocode your locations for this to work.
I have one more suggestion or wis 😉
Suppose i have some 10k listings for a certain location, now Rdius filter could have helped me, but let’s say there ae atleast 5k-8k with in radius filter i set , the map loading could be slow and so the list on the side bar will load slow too.
I have used infinite scroll in my wordpress site , can there be something like that envisioned.
What my vision is have say 50 places in the sidebar list in start and the same on map too, then user scroll the sidebar and a loading gif shows and more listings say another 50 load and pins of same load on map too. if user wants to scroll more he can .
I’m sure if i play around with plugin it could be done , but i would love if you provide a little guidance.
thanks!
Error:
Zip code search returns an error like
Geocode was not succesfull due to follwoing reasons: ZERO_RESULTS
This happens when i am using map inside the wordpress. Map renders fine but search isn’t working. I got rid of jquery from wp-includes which was 1.10.2 . Tried map with 1.10.2 in a syandalone page and page totally fails.
Tried with 1.9.1 and map aswell as zip search works
So can ya tell me is this cause of Jquery version? I am also using Foundation.js , pretty photo scripts besides some custom coded scripts
Plz can ya tell me what could be wrong. Oh i must add here that in 1.9.1 search by zip, city work great
Go ahead an use the jQuery that’s included with WordPress, you shouldn’t need to swap it out. Do you have a link that I could view?
Silly me, how could i let it happen. I had forgot to set ID of the form element as “address”. Trust me i had checked it in firebug and inspect element like 15 times. Thanks for your reply. You perhaps ignored my other question /suggestion about delayed loading or ajax pagination of location lists/pins.
Hi !
First of all, I would like to thank you for this amazing jQuery plugin. You probably spared a lot of people a lot of trouble 🙂
I’ve been able to make he plugin work on a website I work on. I use a KML file containing about 400 locations. Each of these locations are correctly displayed on the map.
Now I’m still having a problem : My client would like to use a custom pin image (a png file) to mark the locations on the map. At some point, in your code, there is this condition:
//Create the markers
if(settings.storeLimit === -1 || settings.storeLimit > 26){
var marker = new google.maps.Marker({
position: point,
map: map,
draggable: false
});
}
else{
var marker = new google.maps.Marker({
position: point,
map: map,
icon: pinImage,
draggable: false
});
}
I replaced the lines above by this :
var marker = new google.maps.Marker({
position: point,
map: map,
icon: “path_to_my_custom_image.png”,
draggable: false
});
But for some reason, even if I remove that condition which use the default icon when the store limit is above 26, my custom image is only displayed as a pin marker if my store limit is under 26. When it reaches 27, the icon displayed is the default Google pin image…
I’ve been trying everything to make it work without success so far. Is there a way to do this?
Maybe just leave it as is and change the “icon” setting in both the if and the else to your custom marker image.
Hi
i’m back again. i was able to get star ratings in sidebar aswell in the info bubble.
Now i’ve another question:
when i type an address or city or zip code in search input box, i want the address bar to update accordingly. Now you can say i can use PUSHSTATE , and i agree , but what i want is that if user types like this in address bar , the map should load new pin locations as per the query
http://www.sitename.com?q=address
please can you guide me and tell me where should i be looking in the code.
That seems like a pretty small edge case but check out the example above at the following link. Some people asked to have the results be on a separate page, which seems really odd to me if you’re using jQuery, but it might help with your issue. I’m not sure if the example is working perfectly anymore but it should be able to get you started – it’s really just a code example and not a fully working one. https://www.bjornblog.com/web/jquery-store-locator-plugin#comment-15691
Hi
i tried the example you listed above, but can’t get it working. Something is missing in there. Can you please look into it?
Hi Bjorn,
it’s me again. Is it possible to create some short of a UI for the variables i.e. number of location, custom image markers etc.? All the handlers in this case…
Rgds,
CJ
Sure, you could. Given the number of settings though it would be a bit of work. I’m slowly working on a WordPress version of this plugin (with all the settings in the admin) but otherwise, I have no plans to do that.
Thanks for your reply Bjorn!
Is it also possible to create some short of a (java)script injection? So it is easily implemented and working without the hassle of coding?
Not that I am aware of.
This seems like a pretty simple question, but who knows. I simply want to remove the letters in the “list-label” and maybe use a small icon instead. Possible?
Simple and easy. Just update the location list template with your desired image: /templates/location-list-description.html
Great! Thanks for the info, Bjorn!
One more simple question. I’m using this plugin for various countries so I need to translate different portions of text. The only area I can’t seem to figure out is on the map modal window where it says “Directions” and “Miles” or “Kilometers”
Can you help me locate where I can manually make these translations? Thanks!
Miles/Kilometers are in the main settings – see the table above. The directions text is in the template files (location-list-description.html).
Thank you for the fantastic plugin. Is there any way to make this work with IE <9?
It should work in IE7 and IE8 – I just looked at the main demo example (linked in the documentation above) and didn’t see any issues other than it not supporting the CSS3 styles. I’m definitely not going to support IE6 at this point.
Hi Bjorn,
This is a great plugin, but I’m struggling to implement multiple searches without a page refresh.
I have a database of over 6,000 locations. I don’t want your plugin to download the entire dataset, so when the form is submitted I’m calling a PHP script which takes the submitted postal code and radius, and returns a pre-filtered collection of stores. The problem that occurs is when I then try another postal code search in a different city — the map changes and centers at the new lat/lng coordinates, but the plugin doesn’t appear to do a new round trip to the server, so it never gets an updated collection of stores from my PHP script.
Is there a workaround for this that doesn’t require a code refresh? I didn’t spot anything obvious.
Thanks,
Ben
A follow-up comment …
It appears that the plugin DOES make follow-up round trips to my PHP script, but it keeps sending the same postal code and distance (radius) data from the initial form submission. I am not clear how to make the plugin update with the live data.
Regards,
Ben
Umm… are you using JSON with your database? Maybe pass the zip over with the ajax data setting. It’s hard to know without looking at your custom stuff.
Hi Bjorn,
One simple question, if I may?
Why do we need to bother with JSON or XML files if we have PHP/MySQL and the data is in a table? As in, can’t I just interrogate the database with a query that brings back the relevant addresses/postcodes?
Many thanks!
Mark.
They don’t need to be separate files. Output your database data as JSON or XML with PHP and set the data source to that PHP file.
i tried to work with php but this doesn’t work , first i outputed the data form mysql and then i changed the value of dataLocation to the php file then i changed dataType to json, when i tested it, the plugin won’t show , after doing an alert test the alert worked on the complete ajax fonction and did’nt work on success fonction, so where is the issue what did i do wrong
Hi
I’ve solved the other problems that i cam across, but now i’ve another question
Q: Can we search by Listing Name ?
i want the search box to say search by keyword, address or zip. the keyword would be the store name.
Can you put me on right track. Plz do reply ASAP!
Regards!
This isn’t something that’s included within the scope of the plugin at the moment and I haven’t looked into it at all. I may add it to a future version though.
Thank you man!
is an update coming any time soon?
I’ve been working on the WordPress version in my spare time but I am going to make several updates to the jQuery before that is released (WP version includes the jQuery plugin and adds all the settings to the admin, among other things). It’s going to be a bigger release with several updates but I don’t have an ETA yet. Most likely within the next month or two. I’ll most likely release both the WP version and jQuery update at the same time.
Thank you bud for keeping me updated! Got a huge snow storm here so kind of delayed in response.
hi Bjorn,
Thanks for the help in the past. Another one (and hopefully simple one!) I have a SQL query pulling data from a table and I sending to the storelocator via JSON. The sort order of the query is ASC by store name, which I confirm when I run the SLQ in phpmyadmin.
When it loads into the map, the loc-list does not show the same sort order. Is there a reason for this or have I done something wrong / missed something?
Thanks!
how did u do to use json instead of xml ??
Got it… commented out “sort_numerically call.
Hi there, great stuff here but I can’t seem to get it to work right. No matter what zip or city I put in, I get my list and map, but it always starts with the very first store on my list. The map will show the correct map for that zip. But prior to my entering a zip, I get a popup message that says “Unfortunately, our closest location is more than 60 miles” but that’s not true. What am I doing wrong?
Oh, I’m using XML with no database
Are you geocoding the your locations in the XML file?
Love the plug in Bjorn, but it is not loving me.
I delete the JSON and KML files, upload your example code to teh server and it runs as intended.
I modify the Locations.XML file and nothing happens. Any hints please?
This is the locations XML file as edited
——————————-
Did you test to make sure the XML is valid? Try running through: http://validator.w3.org/
http://www.html.com.au/mat/storeloc2/locations.xml
Hmm – sorted it – my edited XML file was full of XML errors and not being parsed properly, so the script kept aborting.
This plugin rocks, simple and neat, Thanks again Bjorn
Question, is there a way to use the “know your location” ability of a smartphone or tablet to bypass the “enter your location” stage, and just have a button that says “find your nearest outlet/store”
Having asked that, i feel certain someone has asked in the posts above. Time to do some more reading, YAY 🙂 (still wait for the movie – JQuery Store Locator – to come out 🙂 )
Just set the autoGeocode setting to true
Hi Mat, I am having the same problem as you had. I am editing xml files (for trial) with my own data but unable to load new data in index.html. when i check the html page on local host, it is giving me the same old data.
Please help. Greatly appreciate your time to help me…Thanks.
If you just load the XML file directly in the browser and click refresh, or do a hard refresh, it should update. You could also try adding the cache setting to the main AJAX call to false while you’re working on it but be sure to remove it before going live. Example: after line 333 add:
Will this work without it having to be on a server? If I wanted to play around with it on my desktop, would I be able to get results? I downloaded the gitHub files, but when I run the html files, nothing happens when I enter my zip. The page refreshes but there aren’t any results. The link just adds a # symbol. Is that right?
Never mind. I just saw a post that asked the same thing. Thanks!
Hello Prashnath ,
Can you tell me how did you figure out this as i was just looking for the whole forum ..probably i missed the solution in some post. I was getting this thing
Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
Thanks,
Akhil.
Hi Bjorn, thanks for a great plugin 🙂 for some reason i am unable to get this to work with IE (using version 11 of IE), i have been going through the questions here but i don’t see anything similar…
I don’t have any issue running the demo examples linked above in IE11. Can’t really narrow it down without a link.
Nevermind i got it to work, was a twofold issue related to both iframe tag and jquery version. Thanks again 🙂
Quick question. I have a working map, thanks for this plugin! I send a GET form to the search page and load the map with results. Works fine.
But, if I’m on the search results page, and press F5 for a refresh, I get a blank map. Is their a way to correct this?
Thanks!
Well yeah, it doesn’t store the user’s location. If you want to do that you could use a cookie, session variable, or a database if you’re doing it on a page where the user has to login first.
Bjorn, great plugin here… thanks!
Question: Any idea why my zoom/street view controls are incredibly tiny?
http://imgur.com/2bp0JQq
BTW, pan controls are normal size.
I would guess that it’s most likely a CSS conflict. I’ve seen it myself with Bootstrap – ex: https://github.com/nlaplante/angular-google-maps/issues/129
Hi
Can you tell me where do i need to make changes in code to make this plugin work with SSL support. For now i can’t see it to be working.
Plz reply ASAP!
nvm, i fixed it, but i have a different query. i want to have different pin colors or pin icons for listings. is it possible?
Hi
i tried following code to overide pincolors based on category value, but it won’t work. i can print out the category variable value inside list and info window, but pincolor wont override.
i exactly used the code you put above in reply to Jean’s comment, only thing different is that i’m using json instead of xml.
plz can you look into it or guide me?
my code
//Custom marker function – alphabetical
function createMarker(point, name, address, letter,cat){
if(cat === “Gold Membership”){
var pinColorOverride = “ffd700”;
}
else if (cat === “Silver Membership”) {
var pinColorOverride = “C0C0C0”;
}
else {
var pinColorOverride = “ffd700”;
}
thanks
You might be running into the same thing that Lil Peck is below: https://www.bjornblog.com/web/jquery-store-locator-plugin#comment-23554
Hi
is there a way through which i can safeguard my json output file. i tried session, hash values, but if someone looks inside the firebug, he can easily grab the json file. Also same happens if i use Google Site Speed/insight.
Another Question:
Suppose i’ve set to Full Map start and then use json as source and have 2000 listing, it takes a lot of time to fetch all the results. Any fix to it?
thanks!
Bjorn, Awesome plugin
Question: how to add parameters other than zipcode, radius in search form?
Example: You select zip code, radius and then you also select some category from XML file to filter out search result page
This is probably a simple question, but for the life of me I cannot figure it out. All that I want to do is add another paragraph below the map, yet still within the modal window. Where is the HTML located so I can slide in another div?
Thanks!
Does anyone on here know of a way to use this getting the info from a database. I’m working with asp.net and c#. I’m already querying the database with Linq queries and objectdatasource. I’m wanting it to pretty much like what Bjorn came up with but I am having trouble getting my infromation from the database and using it on the map. I need much help please? Any pointers and links are much appreciated.
HELP!!!!!!! Please…it’s urgent!!! 🙂
The plugin just wraps a div around the map-container div and hides it. So, you should be able to just put your extra content after the map div, within the map-container.
Damn, I thought that myself, but when I tried it yesterday it put the text on the page and not within the modal window. I just tried again and it worked…ugh, sometimes I’m so stupid. I must have forgotten to close my div or something.
Regardless of my eating of stupid pills, I thank you once again 🙂
Hey Bjorn I’m trying to do this using json data but it keeps giving me this error on the console: Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:55271/locations.json. Please help. And yes I have locations.json in the root folder.
Try running the plugin on a remote server or install something like AMPPS, XAMPP, MAMP, WAMP, etc on your local machine if you haven’t already.
I haven’t tried that yet. I’m having an issue with your files or something. I downloaded them and have them all open in Visual Studio 2010 Express for Web and only your index file works, kml and json will not work , it gives me that same error respectively . This is my first dealing with jquery so I dont know exactly whats going on.
I saw a couple of comments about creating an XML file from MySQL database table. Here is a simple script for that: http://rawphp.com/php_generator/page.php?show=Create_XML_file_from_MySQL_table_data.php
hum I’ve created the database.. put some infos in it.. and i’ve tried to run de php script. It created a XML file but there’s nothing inside .. i’ve put all the right info in the mysqli_connect…
Regarding using customized pins: not being very familiar with javascript, I had trouble getting custom pins to work even though I followed the instructions in the comments above. Then I realized that because my “store count” is greater than 26, the custom pins code wasn’t being activated. Where this appears:
//Create the markers
if(settings.storeLimit === -1 || settings.storeLimit > 26){
I put the custom pin code underneath, and now it works.
if(category === “Center”){
var pinColorOverride = “6991fd”;
}
else{
var pinColorOverride = “fe7569”;
}
Yeah, I’m going to try to make category colors easier in the next version.
Bjorn, this is a fantastic piece of work. High quality too.
I’ve yet to explore all the features. Im keen to take my location feed in from my sql tables using php, so ill be looking at some postings here for advice.
One quick question, im using the auto-geocode script example. How would i show the town or full address detected on browser page load?
Many thanks, Paul
Yes, that’s possible. With the auto-geocoding a reverse geocode happens with the determined latitude and longitude points (user’s location) in order to populate the directions links. So, right after line 241 in the current version you could use that originAddress variable and append it to any HTML on your page. I don’t have time to look right now but city might be available separately – if you do JS development you can just do a console log on data to see everything that’s returned.
Bjorn when is an update coming through and when can we purchase the wordpress plugin?
I guess ya been busy with it.
Yep, I’m working on it. It’s difficult to judge when I’m doing it in my free time. I’ve set up all the primary structure with the WordPress version and it’s working. More recently, I started updates on the jQuery plugin. I’ve got a list of stuff I want to change and add (such as easier category filtering setup, prefixing all the CSS, possibly built-in directions, and results pagination among other things) and I’m just working through that. After that’s done I’m going to go back and apply the changes to the WP version and there are a few other things I’ll need to do with the WP version before getting that released like some validation and testing. At this point I’m thinking I probably won’t release both simultaneously and that the jQuery update will come first.
Can the map be made responsive for smart phone display?
I have tried changing some css but unsuccessfully.
Has anyone on here used this plugin in a asp.net web form using json data? If so I need help implementing it.
Love your work!
FYI …………..
I have am using this with no problem in IE 11.0 – but FireFox and Chrome are not working.
In FireFox 28.0 AND 29.0 and Chrome 34.0 getting this error. ‘TypeError: infowindowTemplate is not a function’ – error points to line 771 in jquery.storelocator.js
Haven’t seen that one before. Is the infowindow template loading or do you have an example somewhere? If you look at the AJAX requests in a browser inspector you’ll be able to see if the template requests are failing. I’m thinking it could be a path issue with the infowindow template.
First Bjorn – thank you for creating this, looks great on desktops and tablets. You have probably saved me weeks of work. Works as expected and being a fair novice, I have gotten through the code decently making some adjustments where we need them to be. Only problem I am having right now is getting the map to show up correctly using Bootstrap 3 on the phone. The map is huge on the phone, there is no resizing happening at all.
Can you, or others reading this post, offer some guidance to what I can do to make this presentable on the phone screens?
Thank you again and thanks to you and others for your replies.
I have same issue as the earlier post on May 1, 2014 at 4:50 pm by Jeff.
Paul – if at all possible, I would like to stay in contact with you so that if one of us figures this out we can share the fix. Not sure how to send a private message though. Well, here is my email jcade AT additech.com. Will risk it, need to figure out how to get this to work. Expectations are getting bigger by the day around here.
Are you guys changing the map height with media queries? Basically, what you’d want to do is set up a container with a fixed height, set the width of the map to a percentage, set the map height to 100% and then change the fixed container height with CSS media queries. I whipped up a quick example with bootstrap here that may be helpful to look at: http://bjornblog.com/bootstraplocator/
That looks great – thank you. Yes, I finally got the results I wanted using media queries, although not as good as yours. Will have to look at that at a later date. But for now I have it resizing on the different devices.
Thank you for responding to this.
Hi Bjorn, how to generate dynamic polygons line on google map with given latitudes and longitudes?
Hey Bjorn, You can disregard my last questions I’ve got it working ,but I have just one more question. Is there any known issues where you can’t use this on multiple pages in the same app?
Multiple instances on the same page doesn’t currently work but I don’t see why one instance on multiple pages would be an issue.
It seems to work fine on my search page but when I bring up the details page it wont run again, I’ve even set the default location and it still wont run the code on my details page. My detail page gets the json information for only one location and displays it plus show the map with only that one location.
Never mind I found my issue. Thanks for the help and the plugin, it’s saving me tons of time.
Hi everyone.
Any news on getting the “category” colours to work? I need to be able to split my map up into 4 or 5 different coloured pins. I have the categories already in the xml file, just not sure how to set the pin colours
Thanks
Hello Bjorn, how to trace location on real time? if i change latitude and longitude from backend then it should automatically change the location on google map without refreshing page.
Hi Bjorn,
I am using your storelocator in one of my sample mobile application (developed using PhoneJS). I am not able to understand which jquery method gets called on click of the “submit” button in the index.html file. Also, wanted to know what is the response type it returns. Any help is appreciated.
Thanks in advance
Regards,
Varun
Hello, if you’re not using the ASP.net “noForm” setting it starts on line 309 and it just uses submit by default. It then goes on to get the form value/s in the function above.
Hi, and thanks for this nice plugin 😉
Is it possible to use it with a dynamic json or xml ajax response??
Thankyou
Yes, use the “dataLocation” option to the path of the file that generates the JSON or XML.
Hi Bjorn,
Thanks for replying. Just a quick question can I implement the store locator functionality using PhoneJS (for mobile devices) as it uses Knockout.js. If yes please advice.
Thanks in advance
Regards,
Varun
I’m not familiar with PhoneJS, so I don’t think I can help you with that.
Can anyone help me? I am trying to pass the viewers location (lat, lng) to the data location callback:
getPos = function () {
console.log(“getPos function called”);
navigator.geolocation.getCurrentPosition(function (position) {
console.log(“Successfully retrieved position: “, position);
var coords = position.coords;
$(function() {
$(‘#map-container’).storeLocator({‘slideMap’ : false, ‘dataLocation’ : ‘http://mymap.dev/branch/locations?lat= position.coords.lat&lng=position.coords.lng, ‘infowindowTemplatePath’ : ‘http://mymap.dev/maps/templates/infowindow-description.html’,’listTemplatePath’ : ‘http://mymap.dev/maps/templates/location-list-description.html’} );
});
i.e. how do I pass the users current position into the data location call?
Hi Bjorn,
You can remove my former messge, i managed to get it work as i wanted. however i do have 2 questions please 🙂
1- how can i transmit the user input (#address) to the file in which i create the xml file?
2- i would like to use custom marker, i saw it’s possible as shown in one of the comments, but i couldn’t use the letters with custom markers. how can i do that?
Thank you very much
Hi Bjorn,
Is it possible to display the map by default but only display the list of locations once the location is entered?
Thanks in advance,
Edwin
Thank you so much for this! Working great! http://gotomore.info/index.php
one thing, can i make the map zoom out more?
Thanks for your help ,
Brittany
Yes, just use the “zoomLevel” option. It’s one of the main settings above. Ex:
Hi,
first, special thanks for this script! it’s really good! but I’ve got two questions:
1. is it possible to get the markers without coordinates and only with address from kml file (we’ve got e.g. 500 Stores…. and no coordinates integrated …only this: …) ?
2. the kml file we’ve got, is an export from maps engine – here we can get a network file, too. But this doesnt work with your script. The direct link which is looks like this:
http://mapsengine.google.com/map/kml?mid=blablaLETTER.blablaLETTER
doesnt work, too.
Is there any idea to get this working?
maybe anyone can help?
thx a lot
1. No, you need to geocode all the locations – there are multiple services out there you can use for this.
2. Your link isn’t working anymore so all I can tell you is try to match the formatting of the included KML file.
Hello Bjorn, thank you for this plugin.
I have a question about the list List template, I hope you can help me.
I need to be able to show info based on user role. More info for admins, less info for users.
I work with coldfusion and I would normally replace the HTML with its ColdFusion counterpart to do the conditional display.
However, the way the code works will not allow me to do so.
Do you have any suggestion?
Thank you!
Hello Bjorn, my original question has been solved. Thank you!
Hello,
Did you do this update? I also want it at my website.
If you still don’t have it I’ll try an update by myself and share with you.
Hi,
This is a great plugin! Trying to use it on a dev site that is locked down so I can’t share the URL but hoping you might be able to help – I’m using the autogeocode w/ an XML file, and the map shows my locations but the loc-list div is not being populated. I’ve checked to make sure that the list template path is correct…can you think of anything else that would cause this? I don’t see any errors in my console and this is happening across browsers.
I’m adding this to a site that runs jQuery 1.3.2, which I can’t remove or update, so I have to run the more modern library in parallel w/ no conflict. I don’t think this is the issue but wanted to mention just in case.
Also, are there any limits to how many stores you can list with this plugin? While googling my issue, I came across some stackoverflow posts that seemed to imply that.
Thanks in advance for any help you can provide!
Check to make sure that the handlebars expressions in the template files match the XML keys. Also make sure that you don’t have a CSS conflict – are the list items still showing up and not the content or the entire list altogether?
Thanks for your reply! The entire list is not showing up – ul is empty. The locations are appearing on the map with all the correct information. I have another test server to mess around with and the same exact code works fine over there, so it’s something to do with the CMS that is causing this. So frustrating, as I really want to get this plug in to work, it’s perfect for what I need. Here’s a bit more info on what I’ve tried, in case it offers any clues:
– There are no errors in the console..
– I have checked to ensure the list template path is correct.
– Checked to make sure the ID isn’t being used elsewhere on the page outside of the piece the CMS gives me access to.
– I’ve uploaded all my files to another server I can play with (and referenced the older jQuery library as well as the new one for testing this) and everything works OK there.
– I have tested the .xml file that came with the plugin, as well as the one I wrote with my own locations. Both work in server B but not in server A, so I don’t think the file is problematic. Plus, the locations + info windows are populated correctly in both environments.
What happens if you use the listDiv setting above and use something other than “loc-list” for that setting and in the markup? Also, try removing the id=”list” from the UL tag – I don’t think that’s even being used anymore and it’s a pretty generic name that could be conflicting with something. I’m prefixing everything in the upcoming version that I’m working on.
It’s still not showing up…it’s a mystery. I’m going to have to move on to a different solution but I appreciate your help. I’ll definitely keep this plugin in my pocket for a different site. Thanks!
Hi Bjorn,
I am using the location.xml as my data source. I just wanted to know can we add new html template file and corresponding new xml file apart from the location.xml file. Basically I want to display some more details after the storelistings page is displayed. Please respond it is urgent.
Thanks in advance
Regards,
Varun
I’m not sure I really understand what you’re trying to do. Are you wanting to add more location attributes in the XML and show them in the templates?
Basically once the location.xml is loaded on the screen (UI) I want to show one more screen (UI) on the click event of each store by making the store as anchor tag.
please see the below link wat I am talking about
http://njsams.rutgers.edu/test/njsamslocator/index.html
Note: enter “08540” zip for testing
Please find the link to my application below. Please enter zip “08540” as input to the textbox.
http://njsams.rutgers.edu/test/NJSAMSLocator/index.html
Basically I am adding one more page/template (like the locations display page). From the above link I want a new page to be displayed in place of the test page by clicking on the store locations anchor tag.
Hey Bjorn,
Thank you for the great post! I have a working example running locally on my machine. However, when I upload it to my website, I get a blank page after inserting a Zip Code. Below is the page where it is hosted and any insight would greatly be appreciated!
http://hairoftheferret.com/locations.html
The link doesn’t seem to be working anymore but what usually happens with this kind of thing is people forget to upload the template files.
Hello Bjorn fantastic store locator!
How can i insert a zoom level different from the default for searchbox?
Thx!
http://www.dietnatural.it/storelocator/store-locator.php
Hello,
I’m not sure I understand what you are describing. You want the zoom to change when people search?
Hi Bjorn,
First of all I want to thank you for this great script!
My programming knowledge is very basic, but I hope you can understand my question:
I am using the json file with the php code that you suggest, however I’m having problems with the encoding, as in my language we use special characters. The json file returns “null” for the values where there is any special character. After research and trying different solutions that didn’t solve the issue, I added “$results = mysql_query(“SET NAMES ‘utf8′”);” before your code and now I get the values, but the special characters are not coming as expected (for example “ñ” is coming as “\u00f1”). Do you have any idea of how to solve this?
Apart from this I have another question if you don’t mind. I don’t understand why we need to use json or xml to get the data from the database. Isn’t it possible to get the data directly from the database? I am worried that someone may get access to the php file for the json, and get all the data that the company doesn’t want to share.
Thanks in advance!
What charset are you using for the page in your head meta tag? I believe that would need to be UTF-8 too. If you can’t change the site’s charset you should probably use another method to output the JSON or switch to output XML instead. If you choose to use XML output the XML header with PHP and just build the necessary XML output in the loop – don’t return just echo it out.
Of course there are back-end focused store locators out there. This is JS focused for people who are under some server restriction, want to focus on speed, or are looking for an easy setup. There should be ways around preventing direct PHP file execution. A method I have suggested before would be: 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.
Hey,
The plugin looks great, but I’m having a few issues getting it to work. I downloaded your files from GitHub and tried running the index.html. However, after writing something in the input and clicking submit, nothing happens. If I understand correctly, then downloading your files and testing index.html (not having changed anything) should yield the same results as your demo (http://bjornblog.com/storelocator/)? Or am I doing something wrong?
Actually, never mind.
Turns out it can’t be tested locally. I had to upload it for it to work, which I guess makes sense.
hello,
First of all I want to thank you for this great script!
I have used the store locater plugin, it is fantastic store locator .
I am getting a problem to set the list of all store horizental at the bottom of the map . I don’t get how to set it. i don’t know which parametter i have to pass to the plugin to make all store list horizentaily slidding .
I hope you can understand my question .Please respond it is urgent.
Thanks in advance!
Regards,
Jatinder Garg
It is not a JS setting, it’s just set up with CSS. Change the #loc-list from overflow: auto to overflow-x: auto;
Great code, i modified it and have now a php file that generates only the stores that are needed for the request (using the code from: Josean says:
August 30, 2013 at 9:33 am)
. I like to add category’s aswell in the first page as selection. Any idea how i can get the category in the GET function, i only get value undefined 🙁
Implementation is easy i figured out:
var yournewGETvariable= document.getElementById(“the id of the input field”).value;
And add this to the GET request for the php file
&NameGETvariable=’+yournewGETvariable+’
Hi i just wanna use it with Adobe Muse as I know no coding. I’d like to use the modal window and the way I do that is by grabbing the html of the modal window example and pasting it to a html widget in adobe muse. It seems to work but when I press submit button it gets me error “405 – HTTP verb used to access this page is not allowed.”
Any idea?:( I know its my fault for having very little idea about coding…
Thanks for your reply! I could correct the charset on the page and now I got it right. I’ll look into the session variable, looks like a good solution for my problem.
I really appreciate your help and your sharing this script, I am honestly in no condition to make a donation (I really would if I could, but I am from south america and my money is nothing to you apart from struggling to make a living!), but if there is anything else I can do to return your help (I know html, css, little sql, php… Spanish, anything I may help), you have my email.
I have a question: A client I am developing a site for has requested a feature similar to this, so you have saved me such a headache by offering this to the community and I appreciate it.
I was wondering if it’s possible to ONLY show listings that are located within a certain distance we specify? So, for example, if we (the client/myself) set the range/miles to 30, it will only show listings within 30 miles around the zip code the user inputs.
Is this possible? Again, great tool and I appreciate your hard work on this!
Yes, if you didn’t see it already there is a maxdistance-example.html file included that does what you are wanting.
Sets the standard for KM but is calculating the distance in miles. Where is the problem?
Is giving a difference in the amount of mileage. The value is lower. What can it be?
How do you know it’s not the right calculation? Can you give me an example? The calculation is a direction distance calculation and not a road distance.
great pluging bjorn , i was wandering if some one tryed to get data from mysql directly using php and ajax, i am not a pro in javascript, so i want to know if u could help me to do it ??.
iam using a mysql_query request so there is a chance that it’s won’t be any store found, what i want to do is to write a message to the user if therre is no store found.
woold it be possible.
This will be in the next version, which should be released within the next couple of weeks.
Hi Bjorn,
it’s been a while since our last contact and now i’m struggling with the category filter. I followed your instructions as per https://www.bjornblog.com/web/jquery-store-locator-plugin#comment-15026 however I can’t make the filter work.
What am I doing wrong? Could you or anybody else help me out?
URL: http://test-nieuwe-template.webshopapp.com/verkooppunten/
Great job! Thank you for sharing!
Question: HTML not parsed but displayed
I retrieve the data from a database (-> json). Some fields contain HTML code which I need be able to use on the output (infowindow and list).
Unfortunately HTML code is not being parsed but displayed.
What can I do to have the HTML code diplayed correctly?
Any suggestions are welcome!
That’s a Handlebars thing – you should use 3 brackets around the variables. See HTML Escaping at: http://handlebarsjs.com/
Hey Bjorn
Oh man! Stupid me! Of course. I tried some stuff with handlebar but not the triple-brackets.
Works great!
Again, thank you for your work!
Hi ! first of all, i would like to thank you for the terrific job you did … anyway, i have two simple questions :
1-How can I customize the aspect of the google map ? like changing the saturation of it.
2-I supposed to be using the xml path option … but even when I delete the xml file, the list and locations are still shown, so how could i know if i’am really using the xml option ?
Thanks a lot in advance !
1. In the current version you would need to modify the plugin. Look for the comment “Google maps settings” and add what you want to the myOptions in the else (the second one). In the next version of the plugin I have exposed these settings so they can be modified as an option.
2. Probably just a cached version. Hard refresh your browser, or load the XML file directly in the browser and refresh, or in the AJAX call (line 333) add cache and set it to false while you’re in development and remove when you make it live: http://api.jquery.com/jquery.ajax/
Hello BJorn, is there anyway to get the distance calculation formula adapted to a mySQL query?
I’ve tried myself but I wasn’t able to do it.
Thank you!
Yes, how many locations do you have though? Also, what are you trying to do?
Hi Bjorn!
Thank you for the wonderful plugin!
I’m trying to add categories as per example given earlier to Devin on this forum, with little success.
I was wondering if you might have a link to a working map with categories, so I can see exactly where the code is implemented,
Thank you for any help in advance!
-Aleks
I’m very close to finishing a new version of the plugin that has built-in category filtering support. I’m hoping to have it all finalized within the next couple of weeks. If you’re feeling daring you can try it out with the development branch on Github but none of the updates are documented yet.
Very sweet!!! Thank you for your hard work. Will have to check it out. 🙂