Send address to search in google maps

Asked

Viewed 413 times

1

Hello, I ask for help on the following: I have a Textview with an address, I would like when clicked an Intent sending this address to search in the user’s own Google Maps App.

I know I can use the Google Maps API, but I would like to know if it is possible to send the address to the Google Maps user app.

Thank you

1 answer

3


Examples of use cited in https://developers.google.com/maps/documentation/android-api/intents

Find nearby restaurants:

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

Search for restaurants in São Paulo Capital (based on a specific geo-location):

Uri gmmIntentUri = Uri.parse("geo:-23.564175,-46.6617916?q=restaurants");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

Locate a described address:

Uri gmmIntentUri = Uri.parse("geo:0,0?q=Avenida São João - República, São Paulo - SP");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

With the TextView should look like this:

TextView searchTextField = (TextView) this.findViewById(R.id.searchTextField);

Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + searchTextField.getText().toString());
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
  • 1

    Hi William, thank you so much! Already gave me the code of Textview. It worked that is a beauty!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.