[html] PHP使用Google map web services来计算两点间的距离 -- Compute the distance between two place via Google ma...

Below is PHP code:

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   
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 ;
}

 

转载于:https://www.cnblogs.com/davidhhuan/archive/2010/06/01/1749449.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值