以方向单位km /分钟而不是英里/英尺显示地图框的导航视图

时间:2017-11-09 10:08:49

标签: java android mapbox

如何使用方向单位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);

3 个答案:

答案 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/