有没有办法只用PHP在Google地图中获取给定地址的长/纬度?

And*_*son 12 php google-maps

我知道这在Javascript中是可行的但我只需要使用PHP来做,我该怎么办?

Mik*_*ams 13

是的,有一个HTTP地理编码接口,您可以从任何服务器语言调用.


小智 8

和其他方式:

$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;
Run Code Online (Sandbox Code Playgroud)