是否可以使用谷歌地图从坐标中获取地址? [英] Is it possible to get an address from coordinates using google maps?
本文介绍了是否可以使用谷歌地图从坐标中获取地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是好奇.也许是为了未来的项目.我想知道是否可以通过 Google API 从给定坐标中检索地址.
I'm just curious. Maybe for a future project. I want to know if it's possible to retrieve an address from a giving coordinate via the Google API.
推荐答案
是的.只需使用 Google Geocoding and Places API https://developers.google.com/maps/documentation/geocoding/ 和 https://developers.google.com/maps/documentation/places/
yes. Just use Google Geocoding and Places API https://developers.google.com/maps/documentation/geocoding/ and https://developers.google.com/maps/documentation/places/
示例(源自此处):
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder();
}
function codeLatLng(lat, lng) {
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({
'latLng': latlng
}, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[1]) {
console.log(results[1]);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
这篇关于是否可以使用谷歌地图从坐标中获取地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文