【发布时间】:2011-02-08 08:09:17
【问题描述】:
我正在尝试将 google 地理编码服务与 openlayer 地图一起使用。这应该毫无问题地工作......不是吗? 我使用的代码就像 googles geocode api doc 上的示例:
function geoCode(){
var adresse = $("observation_location_text").getValue();
var geoCoder = new google.maps.Geocoder();
alert(adresse);
geoCoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
marker.moveTo(results[0].geometry.location);
marker.display(true);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
}); }
由于某种原因,我没有得到 Geocoder 对象。永远不会执行带有地址的警报。
期待一些提示 一月
【问题讨论】:
-
哦,顺便说一句,地图和标记变量来自 openlayers,所以这可能不起作用。创建新 Geocoder 对象的调用未返回。
-
您需要注意的是,谷歌地理编码器的 TOS 不幸地规定您使用坐标映射到谷歌地图上。 " 注意:Geocoding API 只能与 Google 地图一起使用;禁止在地图上不显示地理编码结果。有关允许使用的完整详细信息,请参阅 Maps API 服务条款许可限制。"
标签: javascript ruby-on-rails openlayers google-geocoder