maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.01k stars 296 forks source link

Default threshold for the MoveGestureDetector is zero #2792

Open westnordost opened 2 weeks ago

westnordost commented 2 weeks ago

Describe the bug onMoveBegin(detector: MoveGestureDetector) in a MapLibreMap.OnMoveListener is also called when the map is not actually moved but when the user just taps the map.

To Reproduce Register an MapLibreMap.OnMoveListener and log something on onMoveBegin. Start the app and tap the map. Something will be logged.

Expected behavior onMoveBegin(detector: MoveGestureDetector) is only called when the map is moved

Platform information (please complete the following information):

Additional context In StreetComplete, there is a follow-me mode. I.e. the map automatically centers on the current user's location. This is turned off when the user moves the map manually but it should not turn off when the user just taps the map.

Cause of this issue: https://github.com/streetcomplete/StreetComplete/issues/5824

westnordost commented 2 weeks ago

I noticed that the various *GestureDetectors (shove, move, rotate, scale, ...) each have a field named *threshold which governs the minimum movement necessary for the gesture detector to detect the movement.

By setting a breakpoint during the map initialization, I noticed that those various *GestureDetectors actually do have a minimum default threshold set, although I didn't find where it is set. It was 43.5px for the shove gesture, 18.9px for the scale gesture, 3° for the rotate gesture but 0px for the move gesture.

So, wherever these defaults are set, the move gesture should also get some minimum threshold.

louwers commented 2 weeks ago

Here maybe?

https://github.com/maplibre/maplibre-native/blob/bf40cdf5f73403d9855d02a10fdf5eba0a43cbe0/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/location/LocationCameraController.java#L317

westnordost commented 1 week ago

Not sure, maybe at that point, too.

Reading the code vertically, it looks like the LocationCameraController is only used at all when the LocationComponent is used. But the usage of the location component itself is optional, as far as I know. I.e. one might just as well not have a location component.