我想添加到我的应用程序中打开超过 2 个点的 Google 地图应用程序的功能,但我只能设置起点和终点。如何添加航点?
我已经尝试过 uri 中所述https://stackoverflow.com/a/13565504/3626048 https://stackoverflow.com/a/13565504/3626048但它不起作用。在 Google 地图文档中https://developers.google.com/maps/documentation/android/intents https://developers.google.com/maps/documentation/android/intents也没什么。是否有可能向 Google 地图意图添加路径点?
感谢@kaho,“我认为你可以在目的地地址之后使用 +to:waypoint”。
这对我来说适用于多个路点:
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);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)