【发布时间】:2012-11-09 17:08:22
【问题描述】:
我有一个数据库,其中包含准确到建筑物级别的地址。当我将这些手动放入谷歌地图的搜索中时,谷歌地图发现它们没有问题 - 标记出现在正确的建筑物上方。但是,当我使用以下代码将这些相同的地址传递给 Google Maps API 地理编码器时,标记仅显示在街道上,而不是建筑物上。
如何提高准确率?
HTML/PHP:
<div id="addressline"><?php echo theaddress(); ?></div>
JS:
function myGeocodeFirst() {
geocoder = new google.maps.Geocoder();
geocoder.geocode( {'address': document.getElementById("addressline").innerHTML},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
firstLoc = results[0].geometry.location;
map = new google.maps.Map(document.getElementById("map_canvas"),
{
center: firstLoc,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
markers = new google.maps.Marker({
position: firstLoc,
map: map,
});
}
else {
document.getElementById("text_status").value = status;
}
}
);
}
window.onload=myGeocodeFirst;
【问题讨论】:
-
如果您已经有了正确的位置,为什么还要使用地理编码器?您确定 Google 地图报告的位置不是来自 Places 数据库的条目,而不是地理编码器中的条目吗?你能提供例子吗?
-
我没有纬度/经度,只有表格中的地址:123 Road, City, P05T C0D3
-
您有显示问题的示例地址吗?
-
是的,这是一座教堂。它在 Google 地图中显示良好,但 API 指向靠近道路的附近地点:St Clement's Church, Edge Lane, Chorlton, M21 9JF
标签: javascript google-maps-api-3 geocoding