Android Google Map Search Location using Geocoder
In the previous tutorial of Android Google Map and Android Google Map Displaying Current Location we described about display basic Google Map and current location respectively.
Now in this tutorial we will implement location search functionality in Google Map.
Searching location in Google Map API is done through Geocoder class. Geocoder class is used to handle geocoding and reverse geocoding.
Geocoding is a process in which street address is converted into a coordinate (latitude,longitude). Reverse geocoding is a process in which a coordinate (latitude,longitude) is converted into an address.
Methods of Geocoder class
Let's see the code which convert location name into coordinate.
Example of Android Google Map API Searching Location
Let's see an example of Google Map which search input location.
Add a fragment (SupportMapFragment), EditText and Button in activity_maps.xml file.
Add the following dependencies in build.gradel file.
Add the following code in MapsActivity.java file.
Required Permission in AndroidManifest.xml
Add the following user-permission in AndroidManifest.xml file.