Thursday, September 2, 2010

How to get the distance between to location using the google map?

When we calculate the distance between two lat & long the distance would the air to air so distance is wrong,so you have to send both  lat & long to google to get the driving distance.
Given  below the code for it.
//intiat curl
$ch = curl_init();
//pass the  both start and end lat & long
//check google map doc for option
//mode=driving is for driving distance
//sensor=false for site ,for mobile then it is true
//reponse is json
curl_setopt($ch, CURLOPT_URL,
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $contents = curl_exec ($ch);

No comments:

Post a Comment