我寻找在我的旅程中添加航点。
在本例中,下一个路点是在旅程的末尾添加。我想在同一旅程中添加所有的点数。你有主意吗?
发布于 2018-01-24 22:40:09
您可以在使用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();发布于 2018-01-24 18:21:08
谷歌试用this...Using map
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
https://stackoverflow.com/questions/48419893
复制相似问题