I have latitude and longitude - how can I get the name of the street and district?

(data obtained using html5 navigator.geolocation.getCurrentPosition )

Closed due to the fact that the issue is too general for the participants aleksandr barakin , Abyx , insolor , Grundy , Vladimir Martyanov Jan 24 '16 at 13:26 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Through api google or yandex. What is the problem? - Darth

2 answers 2

In the API query string, replace <longitude> and <latitude> with the appropriate values.

 https://geocode-maps.yandex.ru/1.x/?&geocode=E<долгота>,N<широта> 

In response, you will receive xml, where the address is specified in GeocoderMetaData.

For example, for 30.316785 and 59.926353, a query such

 https://geocode-maps.yandex.ru/1.x/?&geocode=E30.316785,N59.926353 

In response, we get xml with the address: Russia, St. Petersburg, Sennaya Square.


The description of API request parameters is here .

You can get the value of <longitude> and <latitude> at https://maps.yandex.ru
To do this, select a point on the map, in the context menu you need to select "what is here?" and in the panel on the right, look at the value of longitude and latitude.

  • For example, St. Petersburg metro garden, found out the coordinates, form the query string geocode-maps.yandex.ru/1.x/... for some reason, I just get Russia, and then Ukraine, Lugansk, etc., where did I go wrong? - zkolya
  • @zkolya < and > it is not necessary to specify. added an example in response - Stack
  • Thank you very much. - zkolya

The answer given by @Stack relates to yandex-maps-api . However, you also have google-maps-api in the tags, so let me answer about google.

So, the principle is the same as in Yandex: in the address bar (or using curl ) you call the address

 https://maps.googleapis.com/maps/api/geocode/json?latlng=<широта>,<долгота>&language=ru 

In the answer we will receive JSON object with the most available data.
For your example it would be like this: https://maps.googleapis.com/maps/api/geocode/json?latlng=59.926353,30.316785&language=ru

And it gives the address down to the house number. Of course, such accuracy is not always possible ...

Remarks:

  • If in the called line replace /json? on /xml? , the refund will be in xml format.
  • The language attribute is optional. If you specify it - the answer will contain the names in Russian. If you do not specify it - the names will be mostly in English