---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/examples/cases/geolocation_control.md
  - https://yandex.com/dev/jsapi-v2-1/doc/ru/v2-1/examples/cases/geolocation_control.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/jsapi-v2-1/doc/ru/llms.txt

# Добавление кнопки "Геолокация"

<iframe id="LIVE-EXAMPLE" style="width:100%;height: 400px;border-radius: 8px;border: 1px solid rgba(92, 94, 102, 0.14);" frameBorder="0" src="https://yastatic.net/s3/front-maps-static/maps-front-jsapi-v2-1/examples/2/out/s3-cases/ru/geolocation_control/index.html" allow="fullscreen"></iframe>

<a target="_blank" rel="noopener noreferrer" style="display: inline-block;margin-top: 10px;cursor: pointer;border-radius: 4px;padding: 9px 12px;background: #151515;color: white;text-decoration: none;font-weight: 500" href="https://codesandbox.io/p/sandbox/p9yljd?file=index.html">Open in CodeSandbox</a>

<div id="references"Геолокация"">
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/ready">ready</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/Map">Map</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/control.GeolocationControl">control.GeolocationControl</a>

</div>
<p>
    В версии API 2.0 для определения местоположения по IP или с помощью <a href="https://www.w3.org/TR/geolocation-API/">Geolocation API</a> разработчикам приходилось самостоятельно
    использовать необходимые методы и обрабатывать полученный результат (см. <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/examples/cases/geolocation_api">пример</a>).
</p>
<p>
    В API 2.1 встроен специальный элемент управления "геолокация", который позволяет отобразить географическое положение пользователя на карте.
    Данный элемент управления реализуется классом <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/control.GeolocationControl">control.GeolocationControl</a>, которому соответствует ключ 'geolocationControl'.
</p>
<p>
    Для добавления элемента управления на карту достаточно указать соответствующий ключ в <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/Map#constructor-summary">параметрах</a> карты.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Добавление кнопки "Геолокация"</title>
            <meta
                http-equiv="Content-Type"
                content="text/html; charset=utf-8"
            />
            <!--
            Укажите свой API-ключ. Тестовый ключ НЕ БУДЕТ работать на других сайтах.
            Получить ключ можно в Кабинете разработчика: https://developer.tech.yandex.ru/keys/
        -->
            
            
            
        </head>
        <body>
            <div id="map"></div>
        </body>
    </html>
    ```

-   geolocation_control.js

    ```js
    ymaps.ready(function () {
        var myMap = new ymaps.Map("map", {
            center: [55.751574, 37.573856],
            zoom: 9,
            controls: ["geolocationControl"],
        });
    });
    ```

{% endlist %}
