S
S
Sergey Saveliev2016-10-11 00:38:07
JavaScript
Sergey Saveliev, 2016-10-11 00:38:07

How to get the region and district due to geocoding in Yandex?

I have only one idea:

var myGeocoder = ymaps.geocode(coords, {results: 1});

myGeocoder.then(
    function (res) {
    	
    	var desc = res.geoObjects.get(0).properties.get('description').split(', '),
    		region = desc[1],
    		rajon = /район/i.test(desc[2])
    			? desc[2]
    			: '';
    	
    	console.log(region, ' :: ', rajon);
    	
    },
    function (err) {
        alert('Ошибка');
    }
);

But it often happens that it is not possible to obtain a district by this method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2016-10-11
@sergej_saveljev

They are not united by Yandex alone, despite the fact that the administrative borders are there from OSM, so it’s better to immediately turn to the original source: Nimonatim

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question