0

I would like to be able to show a geographic map on an Android device and allow the user to be able to click on the map to select the geographic locality that the point is in. For example if I were at Soldier Field in Chicago, my app displays the area around Soldier Field and the user clicks somewhere on the map that is within the boundaries of Chicago and I store the place name Chicago and it's coordinates.

What I have already done is to implement the PlacePicker to show a map representing the current location of the phone and then allow the user to click on a point on the map or a displayed place on the map and then store that point or place. With this I can select the place that represents the geographic locality however it can be very unwieldy. Depending on the zoom level the place "Chicago" may not show up on the visible map and I don't want to have to make the users scroll and zoom to find it. I want them to be able to select a point in the area around Soldier Field and have the app recognize that this point is in the geographic locality of Chicago.

I do not understand how the places and/or google maps apis can be used to recognize the hierarchy of a geographic point (when you have only a geographic point, how do you get to the geographic region -- in this case a city or town -- that the point is in).

Thanks in advance for any assistance.

ronbo4610
  • 101
  • 6

1 Answers1

1

when you have only a geographic point, how do you get to the geographic region -- in this case a city or town -- that the point is in

This is called reverse-geocoding.

You may have a look at Nominatim (http://wiki.openstreetmap.org/wiki/Nominatim) which provides a reverse-geocoding API based on openstreetmap data. The service provides a hierarchy of addresses.

For example, for the location you have cited -

http://nominatim.openstreetmap.org/reverse?format=xml&lat=41.862749&lon=-87.615455&zoom=18&addressdetails=1

But please note that the outcome depends on the crowd-sourced openstreetmap data and may vary from place to place. E.g. it may miss the city / village depending on how well the underlying data is at the region concerned.

headuck
  • 2,763
  • 16
  • 19
  • Thanks. I'm looking to do this using the google maps apis for android not openstreetmap but google seems to have similar reverse geocoding capabilities and I've found a few examples now. I'll take a look. – ronbo4610 Sep 15 '15 at 14:33
  • Once I knew this type of functionality is called reverse geocoding it was pretty simple. I used android.location.Geocoder. Thanks. – ronbo4610 Sep 16 '15 at 15:51
  • Just be aware that, being Google, some intelligent bots may detect a particular usage pattern as abuse, according to criteria that you may never know :) http://stackoverflow.com/questions/8218764/android-geocoder-quota-limits – headuck Sep 16 '15 at 16:20