PHP & AJAX Store Locator

PHP & AJAX Store Locator

An easy-to-configure PHP, AJAX & MySQL store locator script using Google Maps.

  • Language: PHP
  • Released: Aug 8, 2011
    Last Update: Apr 16, 2013

This is a fully featured store locator that you can use to provide easy store locator functionality to your (or your client's) website in under 5 minutes.


  • Easy to configure and set up. (minimal coding skills required)
  • Uses Google Maps API v3 - No API key required!
  • Highly commented, with extra documentation included. (with package)
  • Admin Panel for listing, editing and removing stores.
  • Front-End for adding stores.
  • Easily integrated into existing website - minimal styling, login systems, etc.
  • Uses jQuery library for effects and AJAX.
  • New! JSON API for easy use with apps


Does this script use any JavaScript libraries?

Yes, it uses the latest jQuery library (1.6.2 at time of publishing).

What is "geocoder"/"geocoding"?

Geocoding is the process of converting a string into a latitude/longitude pair. A geocoder is a script/tool that geocodes addresses.

What is "region biasing"?

Region biasing, put simply is biasing results/favoring results from one region over another. For example, let's say a user typed in San Francisco as a location. If the region was set to the US, the geocoder pick San Francisco, CA over other results from other regions, such as San Francisco, Spain. Vice-versa, if the region was set to ES, it would pick San Francisco in Spain. That's why it's very important to set the region.



The configuration of this script is quick and easy, and should not take more than 3 minutes. This requires no skill other than copying/pasting text and editing a basic file.

Almost all of the configuration is done in the settings.php file, which is in the /bin directory. Out of the box, it should look something like this:

//Database Connection information.
$host="hostname"; //usually localhost

//The unit of distance. If you want to use KM instead, put 'kilometers'
$unit = "miles";
$hav_int = 3959;    
//convert the unit string to a number.
if ($unit=="kilometers") {    
    $hav_int = 6371;

Quick Setup (3 Steps)

  1. Unzip the directory into your location of choice (probably /public_html)
  2. Change your database connection information at the top ( the top 4 variables)
  3. Import the 'import.sql' file in the /bin folder which will create a folder called "stores" in your database of choice. Make sure that you are in the database of choice

Once you have done that, you are ready to roll out the script. However, you might want to make some localizations to your script (especially if you're deploying outside of the US).


  1. In order to change default location of the map (from San Francisco, CA), you need to know the latitude and longitude of your new location, (if you don't know you can use a free geocoder like Tiny Geocoder). Then, go to add.js and locator.js (in the "js" folder), and in each file there is a line : var def_coords = {'lat' : 37.775196, 'lng': -122.419204};. replace 37.775196 with your latitude, and replace -122.419204 with your longitude.
  2. Change the $unit variable in settings.php to "kilometers" if you want kilometers, or keep it as miles depending on what is used in your country.
  3. Go to add.js, edit.js, and locator.js (in the "js" directory) and in each file at the top, there is a line: var region = 'us'; if you would like to change the region, you have to change it to ccTLD abbreviation for your country. (the top-level domain name). For example, you could set it to ca, or uk.
You need to log-in or create an account
  • Create an account
  • Log-in
Please use your real name.
Activation link will be sent to this address.
Minimum 8 characters
Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.


Save your watchlist

Fill your details below to receive project updates from your watch list - including new versions, price changes and discounts.

I agree to the terms of use and privacy policy.

3 licenses, starting from From » $9.99 14 day money-back guarantee View Licenses
or Get a quote

for customization or integration services

  • I had this fully up and running in about 10 minutes. Other than knowledge on how to set-up a database, it's all self-explanatory from there and the developer made it nice and easy. Saved me days of coding!
    SO Stephen O'Neal
    3 years ago, 0 comments
    Was this helpful?
  • Excellent component; very well commented, adaptable to other purposes and fantastic value.

    3 years ago, 0 comments
    Was this helpful?
  • Way to go, Souleiman. This is an elegant AJAX store locator that uses a recent JQuery, and I'd not seen one before. As claimed, it was easy to configure and worked right out of the box.
    JO John Ogle
    3 years ago, 0 comments
    Was this helpful?
Post a comment

Or enter your name and Email
  • SC Simon Choy License holderSingle Site 2 years ago
    Hi Souleiman. I've been using your script and modifying a few things. Really happy with it and definitely recommend it to others! There's two features that I wanted to add that are a bit challenging for me, so I wanted to pick your brain. 1. Pre-loading a search so it already displays results when a user visits. For example, on my site say I wanted to have a landing page specifically for New York, I would create one that has all 'stores' from NY already displayed within 50mi range. Been playing around in locator.js but can't get it to work!! 2. Allows registered users to input 'stores'. I know you can do this through add.php but I want the address inputted in separated form (i.e. by country, street, state etc.) instead of one big line so I can sort/filter data. My theoretical solution so far is to geocode user-inputted data through PHP server side ( and then write it to the stores table. PS. I realize providing the solution could be complex and time consuming for you. Even just a nudge in the right direction would be helpful.
  • GC Gus Castaneda 2 years ago
    I wish to buy this, but have few questions... Can it support different screen sizes such as desktop and mobiles? Can map be eleminated from displaying on same page and instead add Get Driving directions on every results list?
    • Souleiman Benhida Developer 2 years ago
      Hi, thanks for showing interest in my script. 1) I'm not sure what you mean by support.. if you mean that it has a specific mobile website part, then no, but the regular desktop version runs fine on iPhones and iPads. 2) As of the current version, you can not get driving directions. I can't imagine it'd be too hard, but sadly it is not in the current version. Perhaps, in a later version I may add it IA but in the meantime you may want to look for another locator that does that. I'm sorry that my locator doesn't have all the features you want, but I think the code is clean and easy to understand and with a decent knowledge of PHP/AJAX you could do anything you want with it! Thanks!
  • Souleiman Benhida Developer 2 years ago
    *double post, see below*