PHP创建Google地图方向链接

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP创建Google地图方向链接相关的知识,希望对你有一定的参考价值。

  1. function googleMapLink($to, $from) {
  2. $destinationAddy = '&daddr='.urlencode($to->getAddress().' '.$to->getCity().' '.$to->getState());
  3.  
  4. if($from) {
  5. $startAddy = '&saddr='.urlencode($from->getAddress().' '.$from->getCity().' '.$from->getState());
  6. } else {
  7. $startAddy = '&saddr=';
  8. }
  9.  
  10. return htmlentities("http://maps.google.com/maps?f=q&hl=en&{$startAddy}{$destinationAddy}");
  11. }

以上是关于PHP创建Google地图方向链接的主要内容,如果未能解决你的问题,请参考以下文章