From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/geolocation/clearwatch/index.html | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 files/ja/web/api/geolocation/clearwatch/index.html (limited to 'files/ja/web/api/geolocation/clearwatch') diff --git a/files/ja/web/api/geolocation/clearwatch/index.html b/files/ja/web/api/geolocation/clearwatch/index.html new file mode 100644 index 0000000000..6c4790a719 --- /dev/null +++ b/files/ja/web/api/geolocation/clearwatch/index.html @@ -0,0 +1,97 @@ +--- +title: Geolocation.clearWatch() +slug: Web/API/Geolocation/clearWatch +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context + - clearWatch + - メソッド + - リファレンス + - 位置情報 + - 位置情報 API + - 安全なコンテキスト +translation_of: Web/API/Geolocation/clearWatch +--- +

{{securecontext_header}}{{ APIref("Geolocation API") }}

+ +

Geolocation.clearWatch()メソッドは、以前 {{domxref("Geolocation.watchPosition()")}} によって登録された位置情報/エラーの監視ハンドラーを解除するために使用します。

+ +

構文

+ +
navigator.geolocation.clearWatch(id);
+ +

引数

+ +
+
id
+
解除したいハンドラーの登録時に {{domxref("Geolocation.watchPosition()")}} メソッドから返された ID 番号です。
+
+ +

+ +
var id, target, option;
+
+function success(pos) {
+  var crd = pos.coords;
+
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+    console.log('Congratulation, you reach the target');
+    navigator.geolocation.clearWatch(id);
+  }
+};
+
+function error(err) {
+  console.warn('ERROR(' + err.code + '): ' + err.message);
+};
+
+target = {
+  latitude : 0,
+  longitude: 0,
+}
+
+options = {
+  enableHighAccuracy: false,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+id = navigator.geolocation.watchPosition(success, error, options);
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Geolocation.clearWatch")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf