HTML5 Geolocation 地理位置 - 6

来源:互联网 发布:python 12306 抢票 编辑:程序博客网 时间:2024/06/15 02:53

Geolocation 地理位置

js:

  navigator.geolocation.getCurrentPosition(
    (
      (pos)->
        alert("当前地理位置的纬度: " + pos.coords.latitude)
        alert("当前地理位置的经度: " + pos.coords.longitude)
        alert("当前地理经度的精度: " + pos.coords.accuracy)
    )
  )

  navigator.geolocation.watchPosition(
    (
      (pos)->
        alert("当前地理位置的变化纬度: " + pos.coords.latitude)
        alert("当前地理位置的变化经度: " + pos.coords.longitude)
        alert("当前地理经度的变化精度: " + pos.coords.accuracy)
        navigator.geolocation.clearWatch(watchID)
    )
  )

原创粉丝点击