码迷,mamicode.com
首页 > Web开发 > 详细

PHP根据地理位置信息获取经纬度

时间:2015-07-25 00:21:04      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:php

不多说了,直接贴代码:

<span style="font-size:14px;"><?php  
$address = !emptyempty($_POST['address'])?$_POST['address']:"上海徐汇区漕宝70号";// Google HQ  
$prepAddr = str_replace(' ','+',$address);  
  
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');  
  
$output= json_decode($geocode);  
  
$lat = $output->results[0]->geometry->location->lat;  
$lng = $output->results[0]->geometry->location->lng;  
  
?>  </span>


版权声明:本文为博主原创文章,未经博主允许不得转载。

PHP根据地理位置信息获取经纬度

标签:php

原文地址:http://blog.csdn.net/evan_cheerup/article/details/47048567

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!