mapbox / mapbox/mapbox-maps-android
Errors when annotation is displayed dynamically
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Android OS version: 14
- Devices affected: Galaxy Tab A8
- Maps SDK Version: compose 11.10.2
## Observed behavior and steps to reproduce
I display annotations dynamically, and when I hide them I can see in logs the following error: `[maps-android\Mbgl-StyleObserver]: OnMapLoadError: Source, message: Source mapbox-android-polylineAnnotation-source-1 is not in style, sourceID: null, tileID: null`
## Expected behavior
The map shouldn't use the removed annotation source.
## Notes / preliminary analysis
the problem is easy to reproduce:
```
Column {
var showAnnotation by remember { mutableStateOf(false) }
Button(onClick = { showAnnotation = !showAnnotation }) {
Text(if (showAnnotation) "hide" else "show")
}
MapboxMap(Modifier.fillMaxSize()) {
if (showAnnotation) {
PolylineAnnotation(
points = listOf(Point.fromLngLat(-180.0, 0.0), Point.fromLngLat(180.0, 0.0))
)
}
}
}
```
Click the button to show the annotation, then click again, and you will see the error in the logs.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Jetpack Compose reproduction using MapboxMap and a conditionally rendered PolylineAnnotation on Android 14 with Maps SDK compose 11.10.2. Reproduce the show-then-hide sequence, then trace the annotation's dynamic removal and source lifecycle; done means hiding the annotation no longer logs an OnMapLoadError for the removed source.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100