gpt4 book ai didi

javascript - Mapbox NavigationViewOptions 和 NavigationLauncherOptions

转载 作者:行者123 更新时间:2023-12-02 08:47:59 26 4
gpt4 key购买 nike

我是 Mapbox 新手,我已经花了几天时间尝试弄清楚如何将 ProgressChangeListener 添加到我的 NavigationLauncherOptions 中。

Mapbox.getInstance(this, getString(R.string.access_token)); setContentView(R.layout.activity_main);

    Point originPoint = Point.fromLngLat(-80.311641,25.910195);
Point destinationPoint = Point.fromLngLat(-80.312159, 25.911922);

NavigationRoute.builder(MainActivity.this)
.accessToken(Mapbox.getAccessToken())
.origin(originPoint)
.destination(destinationPoint)
.build()
.getRoute(new Callback<DirectionsResponse>() {
@Override
public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
currentRoute = response.body().routes().get(0);
NavigationLauncherOptions options = NavigationLauncherOptions.builder()
.directionsRoute(currentRoute)
.shouldSimulateRoute(true)
.build();
NavigationLauncher.startNavigation(MainActivity.this, options);

NavigationViewOptions.Builder optionsNavigate = NavigationViewOptions.builder();
optionsNavigate.progressChangeListener(new ProgressChangeListener() {
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
Log.v("RES", String.valueOf(routeProgress.currentState()));
if (routeProgress.currentState().equals(RouteProgressState.ROUTE_ARRIVED)) {
// Execute arrival logic
}
}
});
}

@Override
public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
}
});

我尝试了附加的代码,但它不起作用。非常感谢任何帮助。谢谢

最佳答案

如上所述here在 Mapbox 的导航 UI SDK 的路线进度文档中:

This listeners is only available if you are adding NavigationView to your Activity or Fragment layout XML via NavigationViewOptions. You are not able to add them to NavigationLauncherOptions.

因此,我建议通过 NavigationViewOptions 而不是 NavigationLauncherOptions 添加 NavigationView,并遵循 Mapbox 的 route progress documentation 中的详细指导。 ,如果您需要访问进度监听器。 mapbox/mapbox-navigation-android示例应用程序还提供了一些有用的示例。

关于javascript - Mapbox NavigationViewOptions 和 NavigationLauncherOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60960168/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com