如何找到两个城市之间的距离(以km或米为单位)[关闭]

I am developing a php web site. Here I want to calculate the distance between two cities. For example: user enters Bangalore as departure and Delhi as the arrival place. I want to find out the distance between Bangalore and Delhi.

Does anyone know how to do this? I have searched a lot; I don't want to enter the co-ordinates.

http://maps.googleapis.com/maps/api/distancematrix/xml?origins=NEW+YORK+11535&destinations=WASHINGTON+20544&sensor=false

refer this http://code.google.com/apis/maps/documentation/distancematrix/

You can use Google Maps API, see this.

You need the coordinates for both cities (from, to). you could get the coordinates on clientside with googlemaps api. here is a tutorial (php) to calculate distances: http://www.phpro.org/tutorials/Geo-Targetting-With-PHP-And-MySQL.html

Try:


http://maps.google.com/maps/nav?q=from:Bangalore%20to:Delhi

The format of the q parameter should be from:xxx%20to:yyy. Replace xxx and yyy with the start and destination respectively. This will return total distance in JSON format: "meters":2077664.