Send address to search google maps

0

Hello, I ask for help on the following: I have a TextView with an address, I would like it when I clicked to make an Intent by sending this address to search the user's Google Maps app itself.

I know I can use the Google Maps API, but I'd like to know if it's possible to send the address to Google Maps from the user's application.

Thank you

    
asked by anonymous 04.12.2016 / 14:44

1 answer

3

Examples of use cited in link

Search 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 restaurants in Sao 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);

Find 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 TextView it 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);
    
04.12.2016 / 19:22