Created
November 13, 2017 14:50
-
-
Save ManishLSN/d405aed1ba9ef066a3b38812ce9c7404 to your computer and use it in GitHub Desktop.
get the distance from two geo location point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&mode=driving&sensor=false"; | |
//you can also pass latitude/longitude values in origins | |
// $details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=41.43206,-81.38992&destinations=San+Francisco&mode=driving&sensor=false"; | |
// $details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=indore+mp&destinations=dewas+mp&mode=driving&sensor=false"; | |
$details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=22.720816,75.874925&destinations=22.721786,75.878326&mode=driving&sensor=false"; | |
$json = file_get_contents($details); | |
$details = json_decode($json, TRUE); | |
// echo "<pre>"; print_r($details); echo "</pre>"; | |
if($details["rows"]["0"]["elements"]["0"]["status"] == "OK"){ | |
echo ($details["rows"]["0"]["elements"]["0"]["distance"]["value"]); //echo "</pre>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment