osmdroid - How to get the city name by latitude and longitude using openstreetmap in android -


in app using osm rather google map.i have latitude , longitude.so here how query city name osm database..plz me.i using osmdroid-android-3.0.8.is there library have download this?

this can done through reverse geocoding, convert latitude/longitude point human readable address. typically, reverse geocoding done web-request.

in case, open street maps has reverse geocoding api can make requests web service , consume xml/json response city name.

making reverse geocode request osm web service this:

http://nominatim.openstreetmap.org/reverse?format=xml&lat=[latitude]&lon=[longitude]&zoom=18&addressdetails=1 

where:

  • [latitude] latitude point reverse geocoded.
  • [longitude] longitude point reverse geocoded.

this give result looks so:

<reversegeocode timestamp="fri, 06 nov 09 16:33:54 +0000" querystring="...">    <result place_id="1620612" osm_type="node" osm_id="452010817">      135, pilkington avenue, wylde green, city of birmingham, west midlands (county), b72, united kingdom    </result>    <addressparts>      <house>135</house>      <road>pilkington avenue</road>      <village>wylde green</village>      <town>sutton coldfield</town>      <city>city of birmingham</city>      <county>west midlands (county)</county>      <postcode>b72</postcode>      <country>united kingdom</country>      <country_code>gb</country_code>    </addressparts>     </reversegeocode> 

you can process result xml document find city name node.

an alternative use google's geolocation api.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -