E
E
Egor Vavilov2012-07-03 20:13:57
JavaScript
Egor Vavilov, 2012-07-03 20:13:57

Processing the response of the geocoder Yandex maps. How to find out the name of the city and street?

Actually, the question is of interest - how to find out the name of the city and the street by coordinates. The user clicks on the map, and in response to him: "The city is such and such, the street is such and such." As far as I can imagine, the only way is to process the AddressDetails. But the necessary items can be at different levels of nesting. Or maybe they don't exist at all.
Is there another way, or maybe there is already a parser for Yandex.maps answers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Isaev, 2012-07-04
@x256

Do you need it through Yandex?
By the way, their implementation of the xAL standard seemed very intelligible to me. The locality is LocalityName(if there are nested ones like Zelenograd, then in DependentLocality), and the street is ThoroughfareName.
If the point is outside the locality ( LocalityNamenone), then you can find the nearest one using the kind=locality parameter . Similarly, the nearest street is found: kind=street . Pay attention to the difference between the last two links: "kind=street" returns a street outside the "kind=locality" locality. It's just that Yandex does not know the names of streets in the nearest villages, so it reported the name of the highway (which is further, beyond the villages). This is life, and Yandex maps reflect it well. I took the settings from here .
I don't really understand the problem with nesting levels. First, the order of the elements there is always the same. Secondly, to be honest, I didn’t even look at nesting, because the string <LocalityName xml:lang="%s">%s</LocalityName>always came to me (at most) one, like ThoroughfareName. Yes, supporters of true XML parsing will forgive me, I stupidly searched for these two lines (well, and others).
Yandex knows much more settlements in Russia than Google, but there was no comparison with other GIS on an industrial scale.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question