Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate a "Search Maps" function in an Android app

The Google Maps application features a search box (with autosuggestion) that allows you to search for an address, resulting in a marker being placed on the map of the Google Maps application.

Is it possible to re-use this functionality in a custom Android app, where a text box is also presented, resulting in a Geopoint being delivered to the custom app, so that the app itself can place the marker somewhere ? In other words, does the Google Maps application expose a service or an intent that can be used by a custom application ?

If so, how can this integration be done ?

If not, can someone provide a pointer on how a custom implementation can be realized ?

like image 255
ddewaele Avatar asked Nov 30 '10 22:11

ddewaele


1 Answers

To acquire a location from a named address, you need to use a statement like Geocoder.getLocationFromName("london",5). It will return a set of matches (5 in this example), you can either use the first one, or show a set to the user to select the right one.

http://developer.android.com/reference/android/location/Geocoder.html

Once you have a location (latitude and longitude) you can then plot the location on the map using a MapOverlay, and show the marker using that.

http://developer.android.com/resources/tutorials/views/hello-mapview.html

like image 161
Ollie C Avatar answered Sep 29 '22 15:09

Ollie C