M
M
Maxim Timofeev2016-04-01 20:44:12
JavaScript
Maxim Timofeev, 2016-04-01 20:44:12

How to determine the city by clicking on it in Yandex maps?

There is a code that displays a map via api:

ymaps.ready(function () {
    var myMap = new ymaps.Map('map', {
            center: [55.751574, 37.573856],
            zoom: 9
        }, {
            searchControlProvider: 'yandex#search'
        });
    myMap.events.add('click', function (e) {
    var coords = e.get('coords');
    $('#city-geo').val(coords);
});  
});

I get the coordinates of the click, but I can’t figure out how to get the name of the city (if there was a click on its territory).
In fact, there is a form where the user adds the city. I need a name and coordinates, I got the coordinates, but with the city there is a problem. I can’t find holes in the documentation for Yandex maps on how to implement this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Faber Estello, 2016-04-01
@webinar

Hold Yandex cards

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question