我搜索为我的旅程添加航点。
在此示例中,下一个航点是在旅程结束时添加的。我想在同一个旅程中添加所有要点。你知道吗?
答案 0 :(得分:1)
您可以在使用NavigationRoute
发出新路线请求时添加路标。
在我们的文档https://www.mapbox.com/android-docs/navigation/overview/中,请查看4. Requesting a route
部分,然后您将找到如何执行此操作的示例。
NavigationRoute.Builder builder = NavigationRoute.builder()
.accessToken(Mapbox.getAccessToken())
.origin(origin)
.destination(destination);
for (Position waypoint : waypoints) {
builder.addWaypoint(waypoint);
}
builder.build();
答案 1 :(得分:0)
试试这个...使用谷歌地图
StringBuilder sb_latlangdrive = new StringBuilder();
for (int i = 0; i < arrayList.size(); i++) {
String split[] = arrayList.get(i).split(",");
sb_latlangdrive.append(split[0] + "," + split[1] + "|");
}
String split[] = arrayList.get(0).split(",");
String split_endlocaiton[] = arrayList.get(arrayList.size() - 1).split(",");
Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=" + split[0] + "," + split[1] + "&destination=" + split_endlocaiton[0] + "," + split_endlocaiton[1] + "&waypoints=" + sb_latlangdrive.toString() + "&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(TrackingTesting.this, "Please install a maps application", Toast.LENGTH_LONG).show();
}
}
有关参考,请参阅doc here