欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
    getCurrentPosition()方法-返回数据
    T若成功,则getCurrentPosition()方法返回对象。始终会返回latitude、longitude以及accuracy属性。如果可用,则会返回其他下面的属性。
    属性描述
    coords.latitude十进制数的纬度
    coords.longitude十进制数的经度
    coords.accuracy位置精度
    coords.altitude海拔,海平面以上以米计
    coords.altitudeAccuracy位置的海拔精度
    coords.heading方向,从正北开始以度计
    coords.speed速度,以米/每秒计
    timestamp响应的日期/时间
    Geolocation对象-其他有趣的方法
    watchPosition()-返回用户的当前位置,并继续返回用户移动时的更新位置(就像汽车上的GPS)。
    clearWatch()-停止watchPosition()方法
    下面的例子展示watchPosition()方法。您需要一台精确的GPS设备来测试该例(比如iPhone):
    实例
var x=document.getElementById("demo");
function getLocation()
{
    if (navigator.geolocation)
    {
        navigator.geolocation.watchPosition(showPosition);
    }
    else
    {
        x.innerHTML="该浏览器不支持获取地理位置。";
    }
}
function showPosition(position)
{
    x.innerHTML="纬度: " + position.coords.latitude + 
    "<br>经度: " + position.coords.longitude; 
}

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h63092.shtml