我想添加我的应用程序以超过2分打开谷歌地图应用程序的能力,但我只能设置起点和终点。如何添加航点? 我按照https://stackoverflow.com/a/13565504/3626048中的描述尝试了uri,但它没有用。在谷歌地图文档https://developers.google.com/maps/documentation/android/intents中,也没有任何关于它。甚至可以将路标添加到谷歌地图意图吗?
答案 0 :(得分:2)
我认为你可以在目的地地址后使用+to:waypoint
。例如:
https://www.google.com/maps?saddr=San+Francisco&daddr=GooglePlex+Mountain+View+to:San+Jose
或者:
答案 1 :(得分:1)
感谢@kaho,对于这个“我认为你可以使用+ to:在目的地址之后的路点。”
这对我来说有多种方式:
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);