aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/geolocation/getcurrentposition
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/api/geolocation/getcurrentposition
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/web/api/geolocation/getcurrentposition')
-rw-r--r--files/ru/web/api/geolocation/getcurrentposition/index.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/files/ru/web/api/geolocation/getcurrentposition/index.html b/files/ru/web/api/geolocation/getcurrentposition/index.html
new file mode 100644
index 0000000000..2a0774dce8
--- /dev/null
+++ b/files/ru/web/api/geolocation/getcurrentposition/index.html
@@ -0,0 +1,82 @@
+---
+title: Geolocation.getCurrentPosition()
+slug: Web/API/Geolocation/getCurrentPosition
+translation_of: Web/API/Geolocation/getCurrentPosition
+---
+<p>{{securecontext_header}}{{ APIRef("Geolocation API") }}Метод <strong><code>Geolocation.getCurrentPosition()</code></strong> используется для получения текущего местоположения устройства.</p>
+
+<h2 id="Синтаксис">Синтаксис</h2>
+
+<pre class="syntaxbox">navigator.geolocation.getCurrentPosition(<em>success[</em>, <em>error[</em>, <em>options]]</em>)</pre>
+
+<h3 id="Параметры">Параметры</h3>
+
+<dl>
+ <dt><code><var>success</var></code></dt>
+ <dd>Функция обратного вызова, которая принимает объект {{domxref("Position")}} в качестве единственного входного параметра.</dd>
+ <dt><code><var>error</var></code> {{optional_inline}}</dt>
+ <dd>Необязательная функция обратного вызова, принимающая объект {{domxref("PositionError")}} как единственный входной параметр.</dd>
+ <dt><code><var>options</var></code> {{optional_inline}}</dt>
+ <dd>Необязательный объект {{domxref("PositionOptions")}}.<br>
+ Включает в себя
+ <ul>
+ <li><code>maximumAge</code>: целое число (миллисекунды) | infinity - максимальное время кеширования позиции.</li>
+ <li><code>timeout</code>: целое число (миллисекунды) - количество времени до вызова callback ошибки. Если 0, вызов не происходит.</li>
+ <li><code>enableHighAccuracy</code>: false | true</li>
+ </ul>
+ </dd>
+</dl>
+
+<h2 id="Пример">Пример</h2>
+
+<pre class="brush: js">var options = {
+ enableHighAccuracy: true,
+ timeout: 5000,
+ maximumAge: 0
+};
+
+function success(pos) {
+ var crd = pos.coords;
+
+ console.log('Ваше текущее метоположение:');
+ console.log(`Широта: ${crd.latitude}`);
+ console.log(`Долгота: ${crd.longitude}`);
+ console.log(`Плюс-минус ${crd.accuracy} метров.`);
+};
+
+function error(err) {
+ console.warn(`ERROR(${err.code}): ${err.message}`);
+};
+
+navigator.geolocation.getCurrentPosition(success, error, options);
+</pre>
+
+<h2 id="Спецификации">Спецификации</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Спецификация</th>
+ <th scope="col">Статус</th>
+ <th scope="col">Комментарий</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('Geolocation')}}</td>
+ <td>{{Spec2('Geolocation')}}</td>
+ <td>Начальная спецификация.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+<p>{{Compat("api.Geolocation.getCurrentPosition")}}</p>
+
+<h2 id="Смотрите_также">Смотрите также</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAPI/Using_geolocation" title="/en-US/docs/WebAPI/Using_geolocation">Using geolocation</a></li>
+ <li>{{domxref("Navigator.geolocation")}}</li>
+</ul>