Reputation: 14179
I want to create a simple web app to find the nearest place from a given position. What I want do is: taken my position through geolocation function in Google maps, find the nearest place in a map. A list of places to be considered is saved in a MySQL db. Every record has two fields: latitude and longitude. After parsing these two values I need to calculate the distance and obtain the nearest place. How can I use JavaScript and PHP to accomplish this?
Upvotes: 2
Views: 2728
Reputation: 4840
Sounds like you're looking for this: Creating a Store Locator with PHP, MySQL & Google Maps.
As a plus, you may want to find the nearest 50 elements and then use the Distance Matrix Service to see how far they are in practice (by driving/walking) to cut down those inital 50 nearest places to those that are the nearest in practice.
Upvotes: 2