Multiple Dot Map Intent

I’m trying to send the intention of Google Maps to show driving directions between several points. I am using the method mentioned here here , but it does not seem to work very well. The ultimate functionality of the application will be to create a URL for the map dynamically, but I created a static one with a bunch of random points for testing:

https://maps.google.com/maps?saddr=San+Francisco,+CA&daddr=Los+Angeles,+CA+to:Phoenix,+AZ+to:Houston,+TX+to:Jacksonville,+FL+to : New + York, + NY + to: Buffalo, + NY + to: Chicago, + IL + to: Seattle, + WA + to: San + Jose, + CA

My exact code is:

 String mapUrl = "https://maps.google.com/maps?saddr=San+Francisco,+CA&daddr=Los+Angeles,+CA+to:Phoenix,+AZ+to:Houston,+TX+to:Jacksonville,+FL+to:New+York,+NY+to:Buffalo,+NY+to:Chicago,+IL+to:Seattle,+WA+to:San+Jose,+CA";
 Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(mapUrl));
 startActivity(i);

If I send this to the browser from the “Full action with” menu, it will work correctly. (FWIW, it also works correctly if I just copy + paste the URL into a web browser on my desktop). On the other hand, if I send it to the Maps application, it means that it is not behaving correctly. On some older devices that I’m running 2.2 and 2.3 on, it shows driving directions, but only two points are marked, one of which is not even one of the points that I missed in the URL, and the routes drive several routes crazy, going back and forth between locations. On any 4.X device, it does not display anything and does not say “Network Failure” or “No Route”. I don't have any 3.X devices, but I expect it to behave similarly to one of them.

MapView, . "", . api, ?

+4
3

:

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();
                        }
                    }

: https://developers.google.com/maps/documentation/urls/guide

+3
final String uri = "http://maps.google.com/maps?daddr=Gachibowli"+"+to:Lingampally+to:Nizampet+to:kukatpally+to:moosapet+to:Nizampet+to:srnagar+to:ameerpet+to:jubileehills+to:kothaguda";
final Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
    startActivity(intent);
}

lat lng, :

final String uri = "http://maps.google.com/maps?daddr=12.972442,77.580643"+"+to:12.9747,77.6094+to:12.9365,77.5447+to:12.9275,77.5906+to:12.9103,77.645";
final Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
if (intent.resolveActivity(MainActivity.this.getPackageManager()) != null) {
    startActivity(intent);
}

* "+", .

+1

Yes, check this link Launch Google Maps Directions via Android Intention

They mentioned both scenarios.

0
source

All Articles