android Mapbox逐行导航问题

时间:2019-05-19 12:38:38

标签: android

我现在正在使用navigationLauncher方法进行导航,但是我想添加一个路由外监听器函数。我已经做了大量研究,以至于NavigationLauncher并不是自定义的好方法,但实际上,这是检测用户偏离路线并重新计算路线的另一种方法吗?

CameraPosition initialPosition = new CameraPosition.Builder()
                            .target(new LatLng(originPoint.latitude(), originPoint.longitude()))
                            .zoom(17f)
                            .build();
                    NavigationLauncherOptions options = NavigationLauncherOptions.builder()
                            .directionsRoute(currentRoute)
                            .shouldSimulateRoute(false)
                            .initialMapCameraPosition(initialPosition)
                            .build();
                    // Call this method with Context from within an Activity
                    NavigationLauncher.startNavigation(fragment_map.this, options);
//I override it and nothing happen if i'm using navigationLauncher
  public void userOffRoute(Location location) {
        originPoint = Point.fromLngLat(mapboxMap.getLocationComponent().getLastKnownLocation().getLongitude(),
                mapboxMap.getLocationComponent().getLastKnownLocation().getLatitude());
        getRoute(originPoint, destinationPoint);
    }

0 个答案:

没有答案