地理定位Geolocation API
地理定位Geolocation API
• getCurrentPosition()函数简介
• getCurrentPosition(successCallback,errorCallback,positionOptions)
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML=请升级浏览器.";}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"<br />Longitude: " + position.coords.longitude;
}