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
Post a Comment