By this request I open the google maps application.

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q="+korOtpr+"(Отсюда)")); startActivity(intent); 

The application opens with a marker indicating the place, but you also need to show the address of this place. What request for this to apply?

  • You do not open the buzz card, you make an implicit request. Any other application working with localization can open. The answer will depend on it. You can not display the address or you can not get it knowing the coordinates? - Shwarz Andrei
  • I want the Google Maps application to show the address by the coordinates that I give to it. - Gennady

2 answers 2

We determine the address by coordinates:

  double latitude = 37.7749; // любые данные double longitude = -122.4194; // любые данные 

...

  Geocoder geocoder; List<Address> addresses; geocoder = new Geocoder(this, Locale.getDefault()); addresses = geocoder.getFromLocation(latitude, longitude, 1); String address = addresses.get(0).getAddressLine(0); 

We put a marker on our coordinates and show the resulting address:

  Uri gmmIntentUri = Uri.parse("geo:" + latitude + ", " + latitude + "?q=" + Uri.encode(address)); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); 

Using googlemaps here is a great guide.

  • Yes, the method is good) I just asked my question here, because I suspect that this method is limited to 1000 requests per day) For guidance, I could not find it at all. - Gennady
  • This is an option that came to mind, well, I still think that it is necessary to write pieces, for example, that if the coordinates do not have an address? or some address is incorrect, you need to do a stub or your class that processes the address according to the input data. You also say that there are restrictions I did not know, I read them the other day and thank you for such a question. - Shwarz Andrei

Use the Geocoder class:

 Geocoder gCoder = new Geocoder(myContext); ArrayList<Address> addresses = gCoder.getFromLocation(123456789, 123456789, 1); if (addresses != null && addresses.size() > 0) { Toast.makeText(myContext, "country: " + addresses.get(0).getCountryName(), Toast.LENGTH_LONG).show(); } 

Read more: here