mapbox / mapbox/mapbox-maps-android

Move gesture does not work correctly at high zoom levels.

Open
#2,675 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Kotlin
Stars
578
Forks
161
PR merge metrics
No merged PRs in 30d

Description

## Environment

- Android OS version: -
- Devices affected: -
- Maps SDK Version: 11.15.0

## Observed behavior and steps to reproduce

On high zoom levels the move gesture does not work correctly. The amount the map is moved is not the same as the finger. It feels weird and unnatural.

Move almost completely breaks at zoom level 25.

## Expected behavior

The move gesture should work correctly at all zoom levels.

## Notes / preliminary analysis

I think this is because CameraOptions discards small movements.

For example the below code will not move the camera at all. The values are small but these small values add up.

```
MapEffect(Unit) { mapView ->
launch {
while (true) {
delay(1)
val currentCenter = mapView.mapboxMap.cameraState.center
mapView.mapboxMap.setCamera(
CameraOptions.Builder()
.center(
Point.fromLngLat(
currentCenter.longitude(),
currentCenter.latitude() + 0.000000001 // very small value
)
)
.build()
)
println("${currentCenter.latitude()} --> ${mapView.mapboxMap.cameraState.center.latitude()}") // Camera latitude DOES NOT change!
}
}
}
```

However, using FreeCameraOptions works.

```
MapEffect(Unit) { mapView ->
launch {
while (true) {
delay(1)
val freeCameraOptions = mapView.mapboxMap.getFreeCameraOptions()
val prevLat = freeCameraOptions.location!!.latitude()
freeCameraOptions.setLocation(
Point.fromLngLat(
freeCameraOptions.location!!.longitude(),
freeCameraOptions.location!!.latitude() + 0.0000000001
)
)
mapView.mapboxMap.setCamera(freeCameraOptions)
println("$prevLat --> ${mapView.mapboxMap.getFreeCameraOptions().location!!.latitude()}") // Camera latitude DOES change.
}
}
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MapEffect reproduction in the issue, comparing CameraOptions and FreeCameraOptions through setCamera and cameraState at high zoom levels. Verify the behavior around zoom level 25 and consider the issue done when move gestures track the finger correctly without losing small movements at all zoom levels.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.