试图向路线添加多个航点,但它甚至没有建立路线:
val builder = NavigationRoute.builder(this@MainActivity) //1
.accessToken(Mapbox.getAccessToken()!!) //2
.origin(originPoint) //3
.destination(endPoint) //4
for (wayPoint in wayPoints) {
builder.addWaypoint(wayPoint)
}
builder.build()
在我的app.gradle中,我还添加了所需的依赖项:
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.42.1'
注意
当我以这种方式在路线中添加单个航点时:
val builder = NavigationRoute.builder(this@MainActivity) //1
.accessToken(Mapbox.getAccessToken()!!) //2
.origin(originPoint) //3
.destination(endPoint) //4
.addWaypoint(wayPoint)
.build()
它正常工作。