I would like to add to my app ability to open Google Maps app with more than 2 points but I can only set start point and end point. How to add waypoints? I've tried uri as described in https://stackoverflow.com/a/13565504/3626048 but it's not working. In Google Maps doc https://developers.google.com/maps/documentation/android/intents there's also nothing about it. Is it even possible to add waypoints to Google Maps intent?
Asked
Active
Viewed 2,856 times
2 Answers
3
Thanks to @kaho, for this "I think you can use +to:waypoint after the destination address."
This works for me with multiple way points:
RealmList<LocationEntity> list = routeEntity.getStops();
ArrayList<Map<String,Object>> latLang = new ArrayList<>();
for (LocationEntity location: list){
latLang.add(location.toMap());
}
String jsonURL = "https://maps.google.com/maps?";
final StringBuffer sBuf = new StringBuffer(jsonURL);
sBuf.append("saddr=");
sBuf.append(destLat);
sBuf.append(',');
sBuf.append(destLong);
sBuf.append("&daddr=");
sBuf.append(sourceLat);
sBuf.append(',');
sBuf.append(sourceLong);
sBuf.append("+to:");
sBuf.append(latLang.get(0).get("latitude"));
sBuf.append(',');
sBuf.append(latLang.get(0).get("longitude"));
sBuf.append("+to:");
sBuf.append(latLang.get(1).get("latitude"));
sBuf.append(',');
sBuf.append(latLang.get(1).get("longitude"));
sBuf.append("+to:");
sBuf.append(latLang.get(2).get("latitude"));
sBuf.append(',');
sBuf.append(latLang.get(2).get("longitude"));
sBuf.append("+to:");
sBuf.append(latLang.get(3).get("latitude"));
sBuf.append(',');
sBuf.append(latLang.get(3).get("longitude"));
sBuf.append("+to:");
sBuf.append(latLang.get(4).get("latitude"));
sBuf.append(',');
sBuf.append(latLang.get(4).get("longitude"));
// sBuf.append("&sensor=true&mode=DRIVING");
sBuf.append("&key=");
sBuf.append("Your_API_KEY");
MISLog.printDebug(sBuf);
Intent sendLocationToMap = new Intent(Intent.ACTION_VIEW,
Uri.parse(sBuf.toString()));
startActivity(sendLocationToMap);

P Yellappa
- 436
- 5
- 11
2
I think you can use +to:waypoint
after the destination address. For example:
https://www.google.com/maps?saddr=San+Francisco&daddr=GooglePlex+Mountain+View+to:San+Jose
Or:

kaho
- 4,746
- 1
- 16
- 24
-
It's not working as Google Maps Intent, when Maps app launches it says that Google Maps can't open link :( – user3626048 Jun 06 '15 at 07:40
-
Oh yea... I think I heard someone said that before on ios's Google map – kaho Jun 06 '15 at 18:28
-
Is there any other way? – user3626048 Jun 07 '15 at 19:38