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 --- .../api/geolocation/getcurrentposition/index.html | 93 ---------------------- 1 file changed, 93 deletions(-) delete mode 100644 files/ja/web/api/geolocation/getcurrentposition/index.html (limited to 'files/ja/web/api/geolocation/getcurrentposition/index.html') diff --git a/files/ja/web/api/geolocation/getcurrentposition/index.html b/files/ja/web/api/geolocation/getcurrentposition/index.html deleted file mode 100644 index dd24b126d3..0000000000 --- a/files/ja/web/api/geolocation/getcurrentposition/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Geolocation.getCurrentPosition() -slug: Web/API/Geolocation/getCurrentPosition -tags: - - API - - Geolocation - - Geolocation API - - Method - - Reference - - Secure context - - getCurrentPosition - - メソッド -translation_of: Web/API/Geolocation/getCurrentPosition ---- -

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

- -

Geolocation.getCurrentPosition() メソッドは、デバイスの現在位置を取得するために使われます。

- -

構文

- -
navigator.geolocation.getCurrentPosition(success[, error[, [options]])
- -

引数

- -
-
success
-
コールバック関数で、 {{domxref("GeolocationPosition")}} オブジェクトを唯一の入力引数として受け取るものです。
-
error {{optional_inline}}
-
任意のコールバック関数で、 {{domxref("GeolocationPositionError")}} オブジェクトを唯一の入力引数として受け取るものです。
-
options {{optional_inline}}
-
任意の {{domxref("PositionOptions")}} オブジェクトです。
- オプションには以下のものがあります。 -
    -
  • maximumAge: 整数 (ミリ秒) | infinity - キャッシュされた位置の最大寿命です。
  • -
  • timeout: 整数 (ミリ秒) - エラーコールバックが呼び出されるまでの時間で、 0 の場合は呼び出されません。
  • -
  • enableHighAccuracy: false | true
  • -
-
-
- -

- -
var options = {
-  enableHighAccuracy: true,
-  timeout: 5000,
-  maximumAge: 0
-};
-
-function success(pos) {
-  var crd = pos.coords;
-
-  console.log('Your current position is:');
-  console.log(`Latitude : ${crd.latitude}`);
-  console.log(`Longitude: ${crd.longitude}`);
-  console.log(`More or less ${crd.accuracy} meters.`);
-}
-
-function error(err) {
-  console.warn(`ERROR(${err.code}): ${err.message}`);
-}
-
-navigator.geolocation.getCurrentPosition(success, error, options);
-
- -

仕様書

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

ブラウザーの互換性

- -

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

- -

関連情報

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