javascript - Distance between two cities in php -


this question has answer here:

i want display events occuring near city database.i tried calculate distance between given city , city using google distance api. problem distance in javascript , have compare integer determmine whether list event or not , repeat process each event. there way pass value javascript php other ajax or other method calculate distance between 2 cities?

i don't see why can't download server directly , 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, can read on google distance here.

you can print_r on $json see structure of response.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -