Как определить район по адресу или координатам с помощью Google Maps API
Размещено 2011-05-13
в разделе Программирование | Метки:
Google, Geolocation, API, Maps
В результатах которые отдает Geocoder Yandex Maps API я подобного не нашел, может плохо искал. Google Maps API когда отдает результаты, то так же показывает информацию о районе и другое, например для Москвы это еще административный округ. Пример URL:
http://maps.googleapis.com/maps/api/geocode/xml?address=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0,%20%D0%9F%D0%B5%D1%82%D1%80%D0%BE%D0%B2%D0%BA%D0%B0,%2038&sensor=false&language=ru
Вот что приходит на запрос "Москва, Петровка 38", Тверской район, Центральный Административный Округ.
<GeocodeResponse> <status>OK</status> <result> <type>street_address</type> <formatted_address>ул. Петровка, 38, город Москва, Россия, 127006</formatted_address> <address_component> <long_name>38</long_name> <short_name>38</short_name> <type>street_address</type> </address_component> <address_component> <long_name>ул. Петровка</long_name> <short_name>ул. Петровка</short_name> <type>route</type> </address_component> <address_component> <long_name>Тверской</long_name> <short_name>Тверской</short_name> <type>sublocality</type> <type>political</type> </address_component> <address_component> <long_name>город Москва</long_name> <short_name>город Москва</short_name> <type>locality</type> <type>political</type> </address_component> <address_component> <long_name>АО Центральный</long_name> <short_name>АО Центральный</short_name> <type>administrative_area_level_2</type> <type>political</type> </address_component> <address_component> <long_name>Москва</long_name> <short_name>Москва</short_name> <type>administrative_area_level_1</type> <type>political</type> </address_component> <address_component> <long_name>Россия</long_name> <short_name>RU</short_name> <type>country</type> <type>political</type> </address_component> <address_component> <long_name>127006</long_name> <short_name>127006</short_name> <type>postal_code</type> </address_component> <geometry> <location> <lat>55.7702350</lat> <lng>37.6125596</lng> </location> <location_type>ROOFTOP</location_type> <viewport> <southwest> <lat>55.7670874</lat> <lng>37.6094120</lng> </southwest> <northeast> <lat>55.7733826</lat> <lng>37.6157072</lng> </northeast> </viewport> </geometry> </result> </GeocodeResponse>