From 972595697b25aa8cbf631f7653e178891efa40a6 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Thu, 3 Feb 2022 01:04:23 +0900 Subject: Geolocation インターフェイスの記事を移行 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/geolocation/clearwatch/index.md | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 files/ja/web/api/geolocation/clearwatch/index.md (limited to 'files/ja/web/api/geolocation/clearwatch/index.md') diff --git a/files/ja/web/api/geolocation/clearwatch/index.md b/files/ja/web/api/geolocation/clearwatch/index.md new file mode 100644 index 0000000000..5ae2a63e7f --- /dev/null +++ b/files/ja/web/api/geolocation/clearwatch/index.md @@ -0,0 +1,95 @@ +--- +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