【问题标题】:watchPosition() and getCurrentPositionwatchPosition() 和 getCurrentPosition
【发布时间】:2012-11-10 17:13:30
【问题描述】:

getCurrentPosition()watchPosition() 有什么区别。我读了几篇关于getCurrentPosition()watchPosition() 的文章。但我都不清楚。据我了解getCurrentPosition() 仅更新一次位置但watchPosition() 不断更新位置。我说的对吗??

【问题讨论】:

  • 你说得对,watchPosition() 每次有新仓位时都会执行回调,getCurrentPosition() 只会在第一个仓位有空时执行一次回调。
  • 下面有人回答了您的问题吗?或者您还有疑问吗?

标签: google-maps geolocation


【解决方案1】:

getCurrentPosition() 给出 currentPosition 纬度和经度值,它只触发一次。其中watchPosition() 连续给出 currentPosition 纬度和经度值。如果位置发生变化(假设你在移动的车辆中,那么watchPosition()会给出结果。然后你就会知道这个结果)

【讨论】:

    【解决方案2】:

    你是对的。 getCurrentPosition() 回调被触发一次,watchPosition() 回调被连续触发。 Good reading on this here.

    【讨论】:

      【解决方案3】:

      watchPosition 每次您的设备位置更改时触发(在 fn 参数中指定间隔)。 getCurrentPostion 只有一次。

      【讨论】:

        猜你喜欢
        • 2010-12-29
        • 1970-01-01
        • 2015-11-13
        • 2019-10-19
        • 2018-03-26
        • 1970-01-01
        • 1970-01-01
        • 2017-10-30
        相关资源
        最近更新 更多