mapbox-navigation-android
mapbox-navigation-android copied to clipboard
Is it possible to hide silent waypoint
Hello Team, i have a small problem with waypoints. I have an array of coordinates of 25 points on which I build a route. I need to make it so that only the start point and end point are visible on the map, and all intermediate points on the map are not visible. During route generation, I specify silent waypoints using the waypointIndicesList(listOf(0, 24) parameter. Navigation considers the specified coordinate indices as silent points, but they are still visible on the route. Although when you specify silent points in the Map Box Navigation IOS, they become invisible on the map! How can they be hidden in the Android version?
private` fun requestRoutes(listOfPoint: ArrayList<Point>) {
MapboxNavigationApp.current()!!.requestRoutes(
RouteOptions
.builder()
.applyLanguageAndVoiceUnitOptions(view!!.context)
.applyDefaultNavigationOptions()
.alternatives(true)
.coordinatesList(listOfPoint)
.waypointIndicesList(listOf(0, 24))
.build(),
object : NavigationRouterCallback {
override fun onCanceled(routeOptions: RouteOptions, routerOrigin: RouterOrigin) {
// no Implement
}
override fun onFailure(reasons: List<RouterFailure>, routeOptions: RouteOptions) {
// no Implement
}
override fun onRoutesReady(
routes: List<NavigationRoute>,
routerOrigin: RouterOrigin
) {
navigationView.api.startRoutePreview(routes)
navigationView.api.routeReplayEnabled(true)
}
}
)
}
Mapbox Navigation SDK version: implementation 'com.mapbox.navigation:ui-app:2.8.0' implementation 'com.mapbox.navigation:ui-dropin:2.8.0'
@IvanMagda-energ Thanks for reporting the issue.
@cafesilencio @LukasPaczos I don't think this is possible with Navigation SDK today. I don't see any means in RouteLineOptions
to mark a waypoint as silent
and hence not associate a drawable with it. Can one of you confirm?
I looks like the NavigationView
is being used in the example above. I'm don't think the NavigationView
supports this option currently. The MapboxRouteLineApi
doesn't expose a feature to hide the intermediate waypoints explicitly but there is a way it could be done if interacting with MapboxRouteLineApi
directly.
@abhishek1508 I can explain how to do this with the MapboxRouteLineApi
if this option is added to NavigationView
.
I looks like the
NavigationView
is being used in the example above. I'm don't think theNavigationView
supports this option currently. TheMapboxRouteLineApi
doesn't expose a feature to hide the intermediate waypoints explicitly but there is a way it could be done if interacting withMapboxRouteLineApi
directly.@abhishek1508 I can explain how to do this with the
MapboxRouteLineApi
if this option is added toNavigationView
.
Thanks for taking a look at this @cafesilencio. I would like to know how could this be achieved using MapboxRouteLineApi
and make necessary adjustments to NavigationView
to support it.
Probably the easiest thing to do would be to add an extension function to MapboxRouteLineApiExtensions
.
Something like:
fun Expected<RouteLineError, RouteSetValue>.replaceWaypoints(wayPoints: List<Point>):
Expected<RouteLineError, RouteSetValue> {
return this.fold({
this
}, { routeSetValue ->
val features = wayPoints.map { Feature.fromGeometry(it) }
val waypointFeatureCollection = FeatureCollection.fromFeatures(features)
val mutableValue = routeSetValue.toMutableValue()
mutableValue.waypointsSource = waypointFeatureCollection
val updatedValue = mutableValue.toImmutableValue()
ExpectedFactory.createValue(updatedValue)
})
}
// basic usage
routeLineApi.setRoutes(
routeLines
) { result ->
// hard coding here for clarity
val origin = Point.fromLngLat(-122.43301555469577, 37.776324454155564)
val destination = Point.fromLngLat(-122.46904197739785, 37.77058251092445)
val updatedResult = result.replaceWaypoints(listOf(origin, destination))
mapboxMap.getStyle()?.apply {
routeLineView.renderRouteDrawData(this, updatedResult)
}
}
Either one of us can add the extension function. You're more knowledgable in how to expose and implement this in NavigationView
.