首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >有没有办法只用PHP就能在Google Maps中获取给定地址的long/lat?

有没有办法只用PHP就能在Google Maps中获取给定地址的long/lat?
EN

Stack Overflow用户
提问于 2009-10-06 14:48:28
回答 5查看 12.2K关注 0票数 12

我知道这在Javascript中是可能的,但我只需要使用PHP就可以了,我该怎么做?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2009-10-06 14:51:44

是的,有一个你可以从任何服务器语言调用的HTTP geocoding interface

票数 13
EN

Stack Overflow用户

发布于 2011-06-12 17:06:31

和其他方式:

代码语言:javascript
运行
复制
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false');

$output= json_decode($geocode);

$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
票数 8
EN

Stack Overflow用户

发布于 2009-10-06 15:00:24

使用Google Map API和PHP获取坐标:

代码语言:javascript
运行
复制
$url = 'http://maps.google.com/maps/geo?q='.$address.'&output=json&oe=utf8&sensor=false&key='.$api_key;
$data = @file_get_contents($url);
$jsondata = json_decode($data,true);
if(is_array($jsondata )&& $jsondata ['Status']['code']==200){
  $lat = $jsondata ['Placemark'][0]['Point']['coordinates'][0];
  $lon = $jsondata ['Placemark'][0]['Point']['coordinates'][1];
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1526057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档