A
A
Anton2018-03-13 18:09:19
API
Anton, 2018-03-13 18:09:19

How to display the city via Yandex API 2.1?

Previously, the city was displayed, but then Yandex removed support for displaying cities in api below 2.1
It is not entirely clear from the documentation how to display now.
Previously, it was possible to display the user's city, either the one specified in the profile settings in the Yandex account, or the real location, if the user allows this location to be determined.
I would like the first option.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
display: block, 2018-03-13
@qork

ymaps.ready(init);

function init(){
  ymaps.geolocation.get({
      // Зададим способ определения геолокации
      // на основе ip пользователя.
      provider: 'yandex',
      // Включим автоматическое геокодирование результата.
      autoReverseGeocode: true
  }).then(function (result) {
      // Выведем результат геокодирования.
      console.log(result.geoObjects.get(0).properties.get('metaDataProperty'));
  });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question