我正在使用反向地理编码API(客户端)将lat,long坐标转换为街道地址 . 这些纬度长度直接来自 Map 上的可拖动标记,因此它们具有许多小数位信息 .
例如,如果我把它放在旧金山,我拖动标记并将{lat,lng}对发送到API . 我得到的东西很像 "San Francisco, CA"
或最好 "South of Market, San Francisco, CA, USA"
.
我知道google在这个区域有街道信息,因为我可以完美地使用前向地理编码API .
是否有任何可能导致此问题的参数?这是我的代码:
maps.reverseGeocode = function(pos, callback) {
maps.geocoder.geocode({
latLng: pos,
bounds: maps.map.getBounds()
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log("Reverse Geocode:", results);
callback(results[0]);
} else {
console.log('Could not geocode: ' + status);
callback(undefined);
}
});
};
其中pos直接来自 Map 标记对象 .
1 回答
很快就想到了这一点 . 这是因为我在请求中包含了
bounds
参数 . 删除bounds
给了我非常准确的结果 . 我现在只在前向地理编码中使用bounds
.