maplibre / maplibre-navigation-android

Maplibre Navigation SDK for Android
MIT License
86 stars 44 forks source link

Current location heading resets when speed=0 #63

Open imranMnts opened 1 year ago

imranMnts commented 1 year ago

Hello,

that's an existing issue on Mapbox side but was fixed normally in 2017 so before the fork of Maplibre if I'm not wrong.

Mapbox ticket: https://github.com/mapbox/mapbox-navigation-android/issues/95

We're facing the same issue, when we stop to move, the camera is doing weird moves.

App configuration setup

  implementation 'com.github.maplibre:maplibre-navigation-android:2.0.0'
  implementation 'org.maplibre.gl:android-sdk:10.0.2'
  implementation 'org.maplibre.gl:android-plugin-annotation-v9:1.0.0'

Expected behaviour The camera should not move when the user stops to move

Actual behaviour The camera is doing weird moves

boldtrn commented 1 year ago

Have you enabled snap on route? Have you changed the route snapping in your code?

Is this issue happening with the navigation sample in this repo?

Fabi755 commented 1 year ago

We also have the same behavior. Even with route snapping enabled.

Thanks for linking the Mapbox issue, this will really helps!

While we also need this fix, I will have a look on this problem after my other issue is finished. Assuming no one is faster 😜

boldtrn commented 1 year ago

I think the linked code should be indeed included in this code base here as well. Maybe there is an edge case in the code? Maybe there is a different issue at play here, as the heading is forced onto the route. We have seen issues like this when using the simulation.

imranMnts commented 1 year ago

@boldtrn It looks like we already have the code present in the PR that I mentioned. Maybe an edge case yes.

I tried with the locationEngine but I didn't test with snapEngine, I'll test and give you my feedback on that.

imranMnts commented 1 year ago

@boldtrn Same behaviour with snapEngine = SnapToRoute()

Don't know if we should set another thing to allow snapEngine to work as expected

Fabi755 commented 1 year ago

Don't know if we should set another thing to allow snapEngine to work as expected

Yes! I made the same mistake. You need to change the following things:

  1. snapToRoute(true)
  2. useDefaultLocationEngine(false)
  3. and call forceLocationUpdate(Location) in ProgressChangeListener
imranMnts commented 1 year ago

Thank you @Fabi755 I tried your suggestion but I have the same behaviour

Looks a bit reduced but the icon is still turning when the speed is reduced to 0km/h