7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Geolocation APIのgetCurrentPosition()よりwatchPosition()のほうが早い気がする

Posted at

スマートフォン用の位置情報を使ったWebアプリを開発していて思った。
**なんか遅えな…!**と。
体感なので詳しいことは調べてないです。

正直watchPosition()だけで十分

id = navigator.geolocation.watchPosition(
  function(position) {
    // 成功時処理
    
    // 処理が終わったらモニタリング終了
    navigator.geolocation.clearWatch(id);
  }, 
  function() {
    // 失敗時処理

    // 処理が終わったらモニタリング終了
    navigator.geolocation.clearWatch(id);
  }, {
    // オプション
  }
);

こうしたら1回処理走って監視終了する。
getCurrentPosition()より断然早い(気がする)のでこの方法使っていこうと思います。

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?