Map search/Get closest place with googlemaps + php + JS?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
caramba
Forum Newbie
Posts: 1
Joined: Mon Jun 23, 2008 4:10 am

Map search/Get closest place with googlemaps + php + JS?

Post by caramba »

Hi I have a small problem that I was wondering if anyone has the answer to. I'm working for a company that has so called base stations placed all over a city (we are like a ISP), and when a customer wants to create a new connection with us we need to know witch base station is the closest so that the customer will get the best bandwidth. So what I would like to do is make a system has a inputbox in where you write the place where the customer lives and then the page checks where the closest station is.
Example:

Steetname: "Yada Yada Yada" [Check] --> PHP+JS script that checks with Google Maps or something like it --> Closest station at "Foo Bar"

Is this even possible? Has it already been done? Can you do this with a combination of a .kml file and a script?

Thanks!

Edit:
I have found out how to calculate the distance between coordinates, the real problem is now that I would like to know how do I get the coordinate of a place, example if I input the address of the customer, I would like to know the coordinate for that place, how do I get that, this might be a tricky question, and I might have to go to the google forums for this, but if anyone here knows about it then it would be great. I have a vision of how the system could work now too...

Vision:
You input the address where the customer lives, and then a map appears, asking you if this is the correct position, if you say yes, a script calculates the distance from all the base stations, and chooses the shortest and then the system tells you the closest station.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Map search/Get closest place with googlemaps + php + JS?

Post by Christopher »

You can get coordinates from an address using Google's API. Check the documentation. Then just find the base station coordinates that are closest to the customer's coordinates with a database search
(#10850)
Post Reply