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

时间:2013-04-10 09:28:42

标签: google-maps geo

我有非工作的谷歌地图。可能有什么问题?

get geo 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>

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

我相信你想使用这个版本的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/