Reputation: 1443
I have a list of users from across the world in JSON format. Each item in the list has a location information.
Is there a Service that I can use?
Do I really need to convert these locations to longitude and latitudes? Essentially all I want to do is find locations withing 50 miles of current location and ignore others.
Upvotes: 1
Views: 1956
Reputation: 8099
You can use the free geonames.org webservice for that. There is a search method available where you can give a location name and get latitude and longitude for any location. Be aware that there may be multiple locations with the same name available. See the example here: http://api.geonames.org/searchJSON?q=london&maxRows=10&username=demo
For your second question, there are multiple approaches. The basic algorithms are outlined in this question, but probably the easiest way is to use the Google Maps API (see second answer to this question).
Upvotes: 3
Reputation: 26066
I’ve done this in the past, at it’s not something one can do simply with just JavaScript & JSON. The best way is to create a MySQL database that uses spatial Point
commands. If you want JavaScript & JSON, then you would have to create a webservice—using PHP for example—to manage the queries between the JavaScript & MySQL database. It seems daunting at first, but once you get the hang of it, it’s quite cool. I recommend reading this site to understand the basics.
Upvotes: 1