Our site has a list of stores around the world. How do we code geolocation ability so we can show the user the nearest shops around them when they enter the Shops page?
Our web visitors have entered that data into our tables; we are not getting the data from a vendor.
I know that HTML5’s Geolocation API will show longitude and latitude, but I don’t understand how one uses that to link it to a database of street addresses. Any ideas for approaches?
One way is to use the google maps api since it has the ability to return locations based on range. You’ll need to construct a json object with your stores and their latitudes and longitudes. If this data ultimately lies on a SQL server on your end you can run a trig based query to order the stores by range from a point and set a distance limit. That should point you in the right direction - I’ve built sites like this but it’s a mild headache to do.
Thank you for giving me pointers! I guess I’ll need to enter each address by hand to get the long/lat, and enter those numbers into the database as well.