0
我试图使用Geolocation API
和Google Maps Geocoder
来获取格式化的用户地址。这一切都很好,但不是在每个地方。例如,my address与纬度42.6462539 21.178498299999998
返回ZERO_RESULTS
...如果您查看地图,这些坐标周围的区域具有足够的数据,那么可以在给定的半径范围内获取近似的地址(例如最近的道路或地点)例如250米Maps API v3如果Geocoder返回ZERO_RESULTS,则获取距离最近的地方
这里是我当前的代码:
if (!navigator.geolocation) alert('Geolocation is not supported by this browser.');
navigator.geolocation.getCurrentPosition(function(position) {
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
geocoder.geocode({latLng: latlng}, function(results, status) {
if (status === 'OK') {
console.log('Geocoding successful.', results);
} else {
console.log('Geocoding failed...', status);
}
});
});
谢谢!
附近的搜索方法做到了。谢谢! – Albion