谷歌地图 - 使用网站上的地址显示地图

问题描述:

我有非工作谷歌地图。什么可能是一个问题?对于GET地理cordinates谷歌地图 - 使用网站上的地址显示地图

代码:

$gmap = file_get_contents ("http://maps.google.com/maps/geo?q=". urlencode($row['gps'])); 
$json = json_decode ($gmap); 
$suradnice = $json->Placemark[0]->Point->coordinates; 
$gps = $s[1] .",". $s[0]; 

嵌入代码:

<iframe width='295' height='360' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/?q={$gps}&amp;ie=UTF8&amp;t=h&amp;z=12&amp;vpsrc=0&amp;ll={$gps}&amp;output=embed'></iframe> 
+0

您的代码是否能够获得坐标?您正在使用已弃用的v2地理编码服务,请参阅[当前版本]的文档(https://developers.google.com/maps/documentation/geocoding/) – geocodezip 2013-04-10 10:00:38

这一过程被称为 “地理编码”。 Here's Google's API for this

+0

该链接适用于已弃用的[Google Maps JavaScript API v2] (https://developers.google.com/maps/documentation/javascript/v2/services)(只保证在2013年5月19日前工作,不建议用于新开发) – geocodezip 2013-04-10 09:57:57

+0

否则,您可以使用[Google Maps Javascript API v3] (https://developers.google.com/maps/documentation/geocoding/#GeocodingRequests) – 2013-04-10 10:24:13

我相信你想用这个版本的Google API作为你的$ file_get_contents参数,其中$ lat和$ lng是经度和纬度。

http://maps.googleapis.com/maps/api/geocode/json?latlng= $纬度,$ LNG &传感器=假”

如果你使用一个地址,这样做:

http://maps.googleapis.com/maps/api/geocode/json?address= $地址&传感器=假”

你可以找到这里的文档: https://developers.google.com/maps/documentation/geocoding/