use*_*267 13 javascript geolocation
我正在使用以下代码,但如何从经度和纬度获取城市名称或位置名称?
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;
}
Run Code Online (Sandbox Code Playgroud)
您可以使用Google Maps v3 API在纬度和经度对上执行反向地理编码.您可以在此处找到如何执行此操作的示例:https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding.
| 归档时间: |
|
| 查看次数: |
29065 次 |
| 最近记录: |