如何使用纬度和经度获取位置名称或城市?
Posted
技术标签:
【中文标题】如何使用纬度和经度获取位置名称或城市?【英文标题】:How do I get location name or city using latitude & longitudes? 【发布时间】:2013-03-27 15:29:56 【问题描述】:我正在使用下面的代码,但是如何从经度和纬度中获取城市名称或位置名称?
var x=document.getElementById("location");
function getLocation()
if (navigator.geolocation)
navigator.geolocation.getCurrentPosition(showPosition,showError);
else
x.innerhtml="Geolocation is not supported by this browser.";
function showPosition(position)
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
【问题讨论】:
en.wikipedia.org/wiki/Reverse_geocoding 试用 Google 地理编码 API developers.google.com/maps/documentation/geocoding 【参考方案1】:您可以使用 Google Maps v3 API 对纬度和经度对执行反向地理编码。您可以在此处找到如何执行此操作的示例:https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding。
【讨论】:
但是位置名称没有出现以上是关于如何使用纬度和经度获取位置名称或城市?的主要内容,如果未能解决你的问题,请参考以下文章