Reputation: 917
I am working on a dating application in PHP: My application has a search page that searches suitable user profiles within certain distance of a person's location (need to specify the no. of miles/kms to search for).
I understand the logic to implement this (ref: Get nearest places on Google Maps, using MySQL spatial data), just not sure where I can get the database that stores the geographical position of each location from around the world. Is this available for free? Would be interested to check out the premium version as well if available.
Also concerned about the query search speeds. Searching across such a huge database is going to cost some overhead, what is the best way to tackle this?
Any suggestions highly appreciated.
Best regards, Seniel
Upvotes: 3
Views: 1443
Reputation: 32148
It sounds very simple ... you ask the user for his address and then request google maps api for the longtitude and latitude like this
http://maps.googleapis.com/maps/api/geocode/json?address=San+Stefano+1+Sofia&sensor=false
and write them in the database.
When the user searchest for nearby people
edit (not going to be a circle, but it will do the job):
SELECT * FROM `users` AS u
WHERE u.lat IS BETWEEN {$my_lat-100} AND {$my_lat+100}
AND u.alt IS BETWEEN {$my_alt-100} AND {$my_lat+100}
like in the post you've mentioned.
Upvotes: 1