Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question