whenever I click on a particular location in Google Map, I want that location's name to be displayed in a text view. Is there any way I can do it?
Asked
Active
Viewed 1,445 times
-5
-
1post your code here – Quick learner Aug 12 '17 at 05:54
-
2Search on Google – IntelliJ Amiya Aug 12 '17 at 06:17
-
@IntelliJAmiya I have already searched it on google.what I found is searching the location from the text view. But not for showing the selected location in text view.If you have any thread can you please provide me here. – ranjit kumar Aug 12 '17 at 06:41
-
https://stackoverflow.com/questions/41849497/how-to-get-address-location-in-lollipop-and-above-using-latitude-and-longitude – IntelliJ Amiya Aug 12 '17 at 06:43
1 Answers
2
Get lat_lng value for particular location, then lat lng value pass to geocoder method.
public void getgetLocationAddress(Context context,double lat,double lng){
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(context, Locale.getDefault());
try {
addresses = geocoder.getFromLocation(lat, lng, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5
address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
country = addresses.get(0).getCountryName();
// System.out.println("SDK_DATA"+address+"..."+city +country);
//Here address set to your textview
} catch (IOException e) {
e.printStackTrace();
} }

RejoylinLokeshwaran
- 494
- 6
- 16