2013-03-27 122 views
11

我正在使用下面的代码,但如何从经度&纬度获取城市名称或地点名称?如何使用纬度和经度获取位置名称或城市?

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; 
} 
+1

http://en.wikipedia.org/wiki/Reverse_geocoding – 2013-03-27 15:30:43

+0

尝试Google地址解析API https://developers.google.com/maps/documentation/geocoding/ – rlemon 2013-03-27 15:32:27

回答

相关问题