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

# geolocation

Static object.

Provides information about the user's location.

[Methods](#methods-summary)

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [get](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geolocation.md#get)(\[[options](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geolocation.md#get-param-options)]) | [vow.Promise](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/vow.Promise.md)
| Tries to determine the user's location. Returns the promise object, which will either be confirmed by the object with the field geoObjects or rejected with an error message. The geoObjects field is an instance of [GeoObjectCollection](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObjectCollection.md). The object that indicates the user's current location will be added to the collection. ||
|#

## Methods details {#method_detail}

### get {#get}

```javascript
{vow.Promise} get([options])
```

Tries to determine the user's location. Returns the promise object, which will either be confirmed by the object with the field geoObjects or rejected with an error message. The geoObjects field is an instance of [GeoObjectCollection](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObjectCollection.md). The object that indicates the user's current location will be added to the collection.

**Returns** Promise object.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`options`](#get-param-options) | — | Type: ||
|| [`options.autoReverseGeocode`](#get-param-options.autoReverseGeocode) | true | Type:

If true, geocode the user position automatically; if false, return as it is. If automatic geocoding is used, the object marking the user's current position has the same structure as the result of executing [geocode](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geocode.md). ||
|| [`options.mapStateAutoApply`](#get-param-options.mapStateAutoApply) | false | Type:

If true, the map center and zoom level are adjusted automatically to show the current location of the user; if false, nothing happens. ||
|| [`options.provider`](#get-param-options.provider) | 'auto' | Type:

Geolocation provider. Accepted values: 'yandex' - geolocation according to the Yandex data, based on the user IP-address; 'browser' - built-in browser geolocation; 'auto' - try to locate the user by all means available and then choose the best value. ||
|| [`options.timeout`](#get-param-options.timeout) | 30000 | Type:

The response time, in milliseconds. ||
|| [`options.useMapMargin`](#get-param-options.useMapMargin) | true | Type: Boolean

Whether to account for map margins [map.margin.Manager](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.margin.Manager.md) when automatically centering and zooming the map. ||
|#


**Examples:**

**1.**

```javascript
ymaps.geolocation.get({
    // Setting the option for determining a user by IP
    provider: 'yandex',
    // The map is automatically centered by the user's position.
    mapStateAutoApply: true
}).then(function (result) {
    myMap.geoObjects.add(result.geoObjects);
});
```

**2.**

```javascript
ymaps.geolocation.get({
    // Setting the option for detecting location by IP provider: 'yandex',
    // Automatically geocoding the result.
    autoReverseGeocode: true
}).then(function (result) {
    // Taking the data resulting from geocoding the object and outputting it to the console.
    console.log(result.geoObjects.get(0).properties.get('metaDataProperty'));
});
```
