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

# Reverse geocoding

<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/en/reverse_geocode/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/rw6jrw?file=index.html">Open in CodeSandbox</a>

<div id="references">
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ready">ready</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map">Map</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geocode">geocode</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects">map.GeoObjects</a>
</div>
<p>
    The API can determine the coordinates of an object by its name and the name of an object by its coordinates (<a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/geocoding">forward and reverse geocoding</a>).
</p>
<p>
    Both types of geocoding are performed using the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geocode">geocode</a> function. The result returned by this function can be immediately placed on the map.
</p>
<p>
    This example uses reverse geocoding, which uses the set coordinates to find the nearest metro station.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. Reverse geocoding</title>
            <meta
                http-equiv="Content-Type"
                content="text/html; charset=UTF-8"
            />
            <!--
                Set your own API-key. Testing key is not valid for other web-sites and services.
                Get your API-key on the Developer Dashboard: https://developer.tech.yandex.ru/keys/
            -->
            
            
            
        </head>
        <body>
            <div id="map" />
        </body>
    </html>
    ```

-   reverse_geocode.js

    ```js
    ymaps.ready(init);

    function init() {
        var myMap = new ymaps.Map(
            "map",
            {
                center: [55.753994, 37.622093],
                zoom: 9,
            },
            {
                searchControlProvider: "yandex#search",
            }
        );

        // Search metro stations.
        ymaps
            .geocode(myMap.getCenter(), {
                /**
                 * Request options
                 * @see https://api.yandex.com/maps/doc/jsapi/2.1/ref/reference/geocode.xml
                 */
                // Only looking for a metro station.
                kind: "metro",
                // Requesting no more than 20 results.
                results: 20,
            })
            .then(function (res) {
                // Setting the image for placemark icons.
                res.geoObjects.options.set("preset", "islands#redCircleIcon");
                res.geoObjects.events
                    // Displaying the hint with the name of the metro station when you hover over the placemark.
                    .add("mouseenter", function (event) {
                        var geoObject = event.get("target");
                        myMap.hint.open(
                            geoObject.geometry.getCoordinates(),
                            geoObject.getPremise()
                        );
                    })
                    // Hiding the hint when the cursor goes off the placemark.
                    .add("mouseleave", function (event) {
                        myMap.hint.close(true);
                    });
                // Adding a collection of found geo objects to the map.
                myMap.geoObjects.add(res.geoObjects);
                // Zooming the map to the collection's viewport.
                myMap.setBounds(res.geoObjects.getBounds());
            });
    }
    ```

{% endlist %}
