php中两个城市之间的距离[重复]

This question already has an answer here:

I want to display events occuring near my city from the database.I tried to calculate the distance between the given city and my city using Google distance API. But the problem is that the distance is in javascript and I have to compare this with some integer to determmine whether to list the event or not and repeat this process for each event. Is there any way to pass value from javascript to php other than ajax or any other method to calculate the distance between two cities?

</div>

I don't see why you can't just download it from your server directly and parse json.

$json=file_get_contents("http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC&destinations=San+Francisco&mode=bicycling&sensor=false");
$json=json_decode($json,true);
$distance=$json["rows"][0]["elements"][0]["distance"]["value"];
echo $distance;

This displays 1677606, you can read up on the google distance here.

You can also print_r on $json to see the structure of the response.