mapbox / mapbox/mapbox-navigation-android
Drop-In Navigation Not Working Correctly.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Kotlin
- Stelle
- 651
- Fork
- 321
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Android API: 33
Mapbox Navigation SDK version:
implementation "com.mapbox.navigation:ui-dropin:2.11.0"
implementation "com.mapbox.navigation:android:2.10.1"
Hello All,
I've been using mapbox for many years now, but It's come to the point I'm required to upgrade to the latest version, I'm currently in the process of developing my application and making the changes to the new version of mapbox.
I'm coming across an issue with the drop-in navigation, when the application starts for the very first time and I provide a MapMatching Navigation Route the app runs fine and the navigation route works, however if I end the navigation or go back from this screen and attempt to run the navigation again the Navigation doesn't work, The route plots on the map but the instructions don't show, the camera doesn't move to the start of the route and the guidance does not start.
I have the following to launch the navigation.
...
binding.navigationView.api.routeReplayEnabled(true)
binding.navigationView.api.startActiveGuidance(listOf(this))
...
Our routes contain approx. 3000-5000 coordinates so we are required to split this out into separate request, and when the first section of the route is about to end we start the next request and so on, but I'm unable to start the next section of the navigation.
MapMatching Request
// Limit Route Coordinates For MAPMATCHING_LIMIT
// If Points Left are Less Than LIMIT Return Remaining.
val subPoints: List<Point>
if (points.size > MAPMATCHING_LIMIT) {
subPoints = points.subList(0, MAPMATCHING_LIMIT)
} else {
subPoints = points
}
// MAP MATCHING REQUEST
val mapboxMapMatchingRequest = MapboxMapMatching.builder()
.accessToken(getString(R.string.mapbox_access_token))
.coordinates(subPoints)
.steps(true)
.tidy(true)
.waypointIndices(0, subPoints.size - 1)
.language(Locale.UK.language)
.voiceInstructions(true)
.bannerInstructions(true)
.profile(DirectionsCriteria.PROFILE_DRIVING)
.build()
MapMatching Response
mapboxMapMatchingRequest.enqueueCall(object : Callback<MapMatchingResponse> {
override fun onResponse(
call: Call<MapMatchingResponse>,
response: Response<MapMatchingResponse>
) {
if (response.isSuccessful) {
Log.d(TAG, "Map Matching Successful.")
response.body()?.matchings()?.let { matchingList ->
Log.d(TAG, "Matchings Count: " + matchingList.size)
matchingList[0].toDirectionRoute().toNavigationRoute(
RouterOrigin.Custom()
).apply {
val bSimulate: Boolean = shouldSimulateRoute()
Log.d(TAG, "Enable Route Simulate? - $bSimulate" )
binding.navigationView.api.routeReplayEnabled(bSimulate)
Log.d(TAG, "Start Guidance for Route")
binding.navigationView.api.startActiveGuidance(listOf(this))
}
}
}
}
override fun onFailure(call: Call<MapMatchingResponse>, t: Throwable) {
Log.d(TAG, "Map Matching Failed. " + t.message)
Toast.makeText(
this@ActivityNav,
"Map Matching Failed. " + t.message,
Toast.LENGTH_LONG
).show()
}
})
Location Observer
private val locationObserver = object : LocationObserver {
override fun onNewLocationMatcherResult(locationMatcherResult: LocationMatcherResult) {
lastLocation = locationMatcherResult.enhancedLocation
}
override fun onNewRawLocation(rawLocation: Location) {
// no impl
}
}
OnCreate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d(TAG, "onCreate()")
binding = ActivityNavBinding.inflate(layoutInflater)
setContentView(binding.root)
// Set to false if you want to handle map long click listener in the app
binding.navigationView.customizeViewOptions {
enableMapLongClickIntercept = false
}
//binding.navigationView.registerMapObserver(mapViewObserver)
MapboxNavigationApp.current()?.registerLocationObserver(locationObserver)
// Start Navigation Automatically.
requestRoute(getCoordinatesData())
}
OnDestroy
override fun onDestroy() {
super.onDestroy()
Log.d(TAG, "onDestroy()")
MapboxNavigationApp.current()?.unregisterArrivalObserver(arrivalObserver)
MapboxNavigationApp.current()?.unregisterRouteProgressObserver(routeProgressObserver)
//binding.navigationView.unregisterMapObserver(mapViewObserver)
MapboxNavigationApp.current()?.unregisterLocationObserver(locationObserver)
/*
if (MapboxNavigationApp.current()?.getTripSessionState() == TripSessionState.STARTED){
MapboxNavigationApp.current()?.stopTripSession()
}
*/
}
Layout
<?xml version="1.0" encoding="utf-8"?>
<com.mapbox.navigation.dropin.NavigationView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:accessToken="@string/mapbox_access_token"
/>
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il ciclo di vita di NavigationView in onCreate e onDestroy, quindi traccia le chiamate a routeReplayEnabled e startActiveGuidance nella risposta Map Matching fornita. Riproduci il primo e il secondo tentativo di navigazione, inclusa la transizione alla sezione successiva del percorso; il lavoro è completato quando la guida, le istruzioni e il movimento della fotocamera funzionano agli avvii successivi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, kotlin
- Ambito
- mobile-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100