【问题标题】:Google Maps API v3 returning incorrect lat/lng for South African addressGoogle Maps API v3 为南非地址返回不正确的 lat/lng
【发布时间】:2015-05-27 10:50:12
【问题描述】:

我正在使用南非地址绘制地图。这通常可以正常工作,但在某些情况下,API 似乎无法找到地址并返回绘制在该国中心的相同纬度/经度。我正在使用以下函数来检索坐标:

function getpointfromaddress(location, callbackfunction){
var geocoderRequest = { address: location, componentRestrictions: {country: 'ZA'} };
geocoder.geocode(geocoderRequest, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var point =  results[0].geometry.location
callbackfunction(point)
}
})
}

不会映射的地址示例是“Corner of Witkoppen & Nanyuki Rd,Sunninghill Park,Sandton,2199”。地址地图很好使用谷歌地图在线。

非常感谢您提供的任何帮助。

【问题讨论】:

标签: google-maps


【解决方案1】:

问题可能是因为您的地址中的“&”。直接从谷歌地图调用地址会生成以下链接。

https://www.google.co.in/maps/search/Corner+of+Witkoppen+%26+Nanyuki+Rd,Sunninghill+Park,Sandton,2199/@-26.029296,28.0215236,14z/data=!3m1!4b1

查询中的“&”替换为“%26”。 您可以在您的程序中通过对地址进行 URL 编码或在 Javascript 中以编程方式替换它来完成此操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-18
    相关资源
    最近更新 更多