在Android Kotlin中无法向地图框添加多个Waypoint

时间:2019-10-28 16:55:38

标签: android kotlin mapbox mapbox-android

试图向路线添加多个航点,但它甚至没有建立路线:

        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()

它正常工作。

0 个答案:

没有答案