Answer the question
In order to leave comments, you need to log in
How to correctly determine the user's city using the Yandex Maps API?
There is this code:
сначала подключаю api
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=тут_мой_ключ" type="text/javascript"></script>
<script>
ymaps.ready(function() {
ymaps.geolocation.get({
provider: 'yandex',
//autoReverseGeocode: true
}).then(function (result) {
var g = result.geoObjects.get(0);
$('#city').html(g.getLocalities()[0]);
});
});
</script>
Answer the question
In order to leave comments, you need to log in
From the mobile you need GPS, well, if the user allows you, of course. Or ask him to explicitly specify the city. The IP address that is given to the mobile in the databases is tied to the operator's head office. Here he is in Moscow, and you can even go to Alaska, this will not cause a miracle in the database and the position of the address will not change.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question