Below is PHP code:

 

代码
function distance($lat1, $lng1, $lat2, $lng2)
{
$url = "http://maps.google.com/maps/api/directions/xml?origin=".$lat1.",".$lng1."&destination=".$lat2.",".$lng2."&sensor=false";
$tem = simplexml_load_file($url);
$tem->registerXPathNamespace("tem", "http://www.w3.org/2005/Atom");
$rs = 0;
for($i = 0; $i<count($tem->route->leg->step); $i++)
{
$rs += $tem->route->leg->step[$i]->distance->value;
}
return $rs;
}

 

相关文章:

  • 2021-06-05
  • 2022-12-23
  • 2022-02-26
  • 2021-11-22
  • 2022-02-27
  • 2022-01-01
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2022-01-21
相关资源
相似解决方案