0

enter image description here

Here is the code that the button link to google maps based on the textview address.

button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view){
                    String address = textViewAddress.getText().toString();
                    String addressb = textViewAddressB.getText().toString();
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q="+address));
                    view.getContext().startActivity(intent);
                }
            });

How can I intent to multiple destinations/points in Google Maps? So If I created another textview address b, I want to show the location address a to address b to address c like the image above. Also possible intent to Waze as well?

veen259
  • 33
  • 9

1 Answers1

1

You can refer to this API Documentation.. by using waypoints you may add multiple destinations

Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=18.519513,73.868315&destination=18.518496,73.879259&waypoints=18.520561,73.872435|18.519254,73.876614|18.52152,73.877327|18.52019,73.879935&travelmode=driving");
Intent intent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
intent.setPackage("com.google.android.apps.maps");
try {
    startActivity(intent);
} catch (ActivityNotFoundException ex) {
    try {
        Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
        startActivity(unrestrictedIntent);
    } catch (ActivityNotFoundException innerEx) {
        Toast.makeText(this, "Please install a maps application", Toast.LENGTH_LONG).show();
    }
}

Update You can also check this question

ColdFire
  • 6,764
  • 6
  • 35
  • 51