From b9941d9eedfe157f53d4d3a7265b83f1fbc785f2 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Thu, 3 Feb 2022 01:30:02 +0900 Subject: 2022/01/20 時点の英語版に同期 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/geolocation/getcurrentposition/index.md | 99 +++++++++------------- 1 file changed, 41 insertions(+), 58 deletions(-) diff --git a/files/ja/web/api/geolocation/getcurrentposition/index.md b/files/ja/web/api/geolocation/getcurrentposition/index.md index dd24b126d3..158accd2cf 100644 --- a/files/ja/web/api/geolocation/getcurrentposition/index.md +++ b/files/ja/web/api/geolocation/getcurrentposition/index.md @@ -4,43 +4,43 @@ slug: Web/API/Geolocation/getCurrentPosition tags: - API - Geolocation - - Geolocation API - - Method - - Reference - - Secure context - - getCurrentPosition + - 位置情報 API - メソッド + - リファレンス + - 安全なコンテキスト + - getCurrentPosition +browser-compat: api.Geolocation.getCurrentPosition translation_of: Web/API/Geolocation/getCurrentPosition --- -

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

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

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

+**`Geolocation.getCurrentPosition()`** メソッドは、端末の現在位置を取得するために使われます。 -

構文

+## 構文 -
navigator.geolocation.getCurrentPosition(success[, error[, [options]])
+```js +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
  • -
-
-
+- `success` + - : コールバック関数で、 {{domxref("GeolocationPosition")}} オブジェクトを唯一の入力引数として受け取ります。 +- `error` {{optional_inline}} + - : オプションのコールバック関数で、 {{domxref("GeolocationPositionError")}} オブジェクトを唯一の入力引数として受け取ります。 +- `options` {{optional_inline}} + - : オプションのオブジェクトで、以下の引数を含みます。 + - `maximumAge` + - : 正の `long` 値で、キャッシュされた位置を返すことが可能な最大時間をミリ秒単位で表します。 `0` に設定した場合、端末はキャッシュされた位置を使用できず、実際の現在位置を取得する必要があることを意味します。 [`Infinity`](/ja/docs/Web/JavaScript/Reference/Global_Objects/Infinity) に設定した場合、端末はキャッシュされた位置をその古さに関係なく返さなければなりません。既定値は 0 です。 + - `timeout` + - : 正の `long` 値で、端末が位置を返すために掛けることができる最大時間をミリ秒単位で表します。既定値は [`Infinity`](/ja/docs/Web/JavaScript/Reference/Global_Objects/Infinity) で、 `getCurrentPosition()` は位置を取得できるまで返さないという意味です。 + - `enableHighAccuracy` + - : 論理値で、アプリケーションが可能な限り正確な結果を受け取ることを望んでいることを示します。もし `true` で、端末がより正確な位置を提供できる場合は、そのようにします。この場合、応答時間が遅くなったり、消費電力が増加したりすることに注意してください(たとえば、モバイル端末の GPS チップを使用する場合など)。一方、 `false` の場合、端末はより速く反応したり、より少ない電力を使用することで、リソースを節約することができます。既定値は `false` です。 -

+## 例 -
var options = {
+```js
+var options = {
   enableHighAccuracy: true,
   timeout: 5000,
   maximumAge: 0
@@ -60,34 +60,17 @@ function error(err) {
 }
 
 navigator.geolocation.getCurrentPosition(success, error, options);
-
- -

仕様書

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

ブラウザーの互換性

- -

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

- -

関連情報

- - +``` + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- [位置情報 API の使用](/ja/docs/Web/API/Geolocation_API/Using_the_Geolocation_API) +- {{domxref("Navigator.geolocation")}} -- cgit v1.2.3-54-g00ecf