如何使用方向单位navigationview
而非mapbox
km/minutes
miles/feets
String awsPoolId = null;
boolean simulateRoute = false;
Log.e("=origin==", "" + origin);
Log.e("=desti==", "" + destination);
// Call this method with Context from within an Activity
NavigationLauncher.startNavigation(GotoPickup.this, origin, destination, awsPoolId, simulateRoute);
答案 0 :(得分:0)
您必须设置所需的类型(METRIC)。我从Mapbox计算路线(注意语音指令)并将其传递给NavigationLauncher:
NavigationRoute.builder()
.voiceUnits(DirectionsCriteria.METRIC)
...
.build()
.getRoute(new Callback<DirectionsResponse>() {
// Checkout mapbox tutorials for this part
DirectionsRoute directionsRoute = ...
NavigationLauncherOptions options = NavigationLauncherOptions.builder()
.directionsRoute(directionsRoute)
.unitType(NavigationUnitType.TYPE_METRIC)
.build();
NavigationLauncher.startNavigation(MyActivity.this, options);
}
});
使用com.mapbox.mapboxsdk可以正常工作:mapbox-android-navigation-ui:0.13.0
答案 1 :(得分:-1)
all objects are:- Global define
com.mapbox.mapboxsdk.geometry.LatLng originCoord;
Point originPosition;
Point origin;
originCoord = new com.mapbox.mapboxsdk.geometry.LatLng(23.040105, 72.561381);
originPosition = Point.fromLngLat(originCoord.getLongitude(), originCoord.getLatitude());
origin = originPosition;
Pass "origin" on " .origin(origin)" directly
Destination is same as this
final NavigationViewOptions options = NavigationViewOptions.builder()
.origin(origin)
.destination(destination)
.awsPoolId(awsPoolId)
.shouldSimulateRoute(simulateRoute)
.build();
// Call this method with Context from within an Activity
NavigationLauncher.startNavigation(MainActivity.this, options);
答案 2 :(得分:-1)
// See this is only for Navigation of mapbox if you are using mapbox that you //can use this code directly for navigation
// First, we have to define Latlng of mapbox
com.mapbox.mapboxsdk.geometry.LatLng originCoord;
//than put your your lat,lng in this like that
originCoord = new com.mapbox.mapboxsdk.geometry.LatLng(23.040105, 72.561381);
// Now, for navigation we mapbox want "Point" type of datatype so we have //to change Latlng to point type like that...
Point origin;
Point originPosition;
originPosition = Point.fromLngLat(originCoord.getLongitude(), originCoord.getLatitude());
// than i will put this point type data to other point type because. i need //it. you can directly put this point on navigation class
origin = originPosition;
//like that....
final NavigationViewOptions options = NavigationViewOptions.builder()
.origin(origin)
.destination(destination)
.awsPoolId(awsPoolId)
.shouldSimulateRoute(simulateRoute)
.build();
// Call this method with Context from within an Activity
NavigationLauncher.startNavigation(MainActivity.this, options);
// in this code i will show you only for source LatLng you have to do same //for destination code
/// hope you will understand that ......
//If you not using mapbox refer this link.....https://www.mapbox.com/