现在的位置: 首页 > 综合 > 正文

HTML5 Geolocation 地理位置 – 6

2018年09月09日 ⁄ 综合 ⁄ 共 473字 ⁄ 字号 评论关闭

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)
    )
  )

抱歉!评论已关闭.