You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable location tracking with the code above (camera will move to user's last coordinate).
Do not receive any coordinate updates.
Disable location tracking by manually moving the camera.
Get new coordinate.
Observed behavior:
The camera returns to the previous location as if location tracking was still active (but with the previous coordinate, not the new coordinate). After this, if we receive new coordinates, then everything is as expected: location tracking is disabled.
Expected behavior
If we disable location tracking (either by moving the camera or by calling viewport.idle()), then it no longer affects the camera in any way, all internal deferred actions are cancelled in ViewportPlugin.
Notes / preliminary analysis
In the debug I saw that FollowPuckViewportStateImpl.stopUpdatingCamera() is called, in which removeIndicatorListenerIfNeeded() is called. In removeIndicatorListenerIfNeeded() there is such code
private fun removeIndicatorListenerIfNeeded() {
if (isObservingLocationUpdates && dataSourceUpdateObservers.isEmpty() && !isFollowingStateRunning) {
locationComponent.removeOnIndicatorPositionChangedListener(indicatorPositionChangedListener)
locationComponent.removeOnIndicatorBearingChangedListener(indicatorBearingChangedListener)
isObservingLocationUpdates = false
// when unsubscribed from the location updates, we don't want to keep an outdated location, so
// when user transition to the FollowPuckViewportState, there wouldn't be any unintentional jump.
lastBearing = null
lastLocation = null
}
}
@Copatych thank you for the detailed report.
Unfortunately, I can't reproduce the issue. Maybe you forgot to provide some mapView.location settings that cause such behavior.
I would appreciate it if you provide a reproducible example.
We have implemented a custom LocationProvider that retrieves location data either from the Android LocationManager or from mock locations created by tapping on the map. We are also utilizing the LocationCompassEngine, which we've adapted from Mapbox version 11.2.1 (According to Mapbox's response #2064, they do not intend to make the API public).
The issue is most easily observed when moving over significant distances. This is primarily due to the camera movements becoming more noticeable. On certain smartphones, the compass can introduce additional complications. This is because we treat any rotation of the smartphone as "coordinate updates" (accordingly, point 2 of "Steps to reproduce" may be violated). Some devices trigger such events even without actual physical rotation, for instance, when lying flat.
To improve the consistency of reproduction, it's advisable to disable events about changes in bearing. This helps reduce interference from the compass on smartphones that report changes even when not in motion.
Environment
Observed behavior and steps to reproduce
There is an unexpected camera behavior when using location tracking
Steps to reproduce:
Observed behavior:
The camera returns to the previous location as if location tracking was still active (but with the previous coordinate, not the new coordinate). After this, if we receive new coordinates, then everything is as expected: location tracking is disabled.
Expected behavior
If we disable location tracking (either by moving the camera or by calling viewport.idle()), then it no longer affects the camera in any way, all internal deferred actions are cancelled in ViewportPlugin.
Notes / preliminary analysis
In the debug I saw that FollowPuckViewportStateImpl.stopUpdatingCamera() is called, in which removeIndicatorListenerIfNeeded() is called. In removeIndicatorListenerIfNeeded() there is such code
dataSourceUpdateObservers is not empty.
If replace
with
then there is no such problem. And dataSourceUpdateObservers is empty on stopUpdatingCamera().
The text was updated successfully, but these errors were encountered: