首页 > 代码库 > html5Geolocation地理定位

html5Geolocation地理定位

<html>
<head>
    <title>Geolocation API地理定位</title>
    <script type="text/javascript">
        navigator.geolocation.getCurrentPostion(function(pos) {
            console.log("当前地理位置的纬度:" + pos.coords.laitude);
            console.log("当前地理位置的经度:" + pos.coords.longitude);
            console.log("当前经纬度的经度:" + pos.coords.accuracy);
        });

        var watchID = navigator.geolocation.witchPosition(function(pos) {
            console.log("当前位置变化的纬度:" + pos.coords.laitude);
            console.log("当前位置变化的经度:" + pos.coords.longitude);
            console.log("当前位置变化的经度:" + pos.coords.accuracy);

            navigator.geolocation.clearwatch(watchID);
        }, function() { });
    </script>
</head>
<body>

</body>
</html>

html5Geolocation地理定位