mapbox-maps-android
mapbox-maps-android copied to clipboard
PointAnnotations disappear/reappear depending on zoom level
Environment
- Android OS version: Android 34
- Devices affected: Pixel 5
- Maps SDK Version: 11.3.0-beta.1
Observed behavior and steps to reproduce
After applying a filter that impacts the data source for a PointAnnotationGroup, PointAnnotation visibility does not persist, individual PointAnnotations disappear and re-appear depending on zoom level.
See screen recording at https://brendanw.s3.us-west-2.amazonaws.com/pointAnnotationIssue.mov
I didn't have this issue before switching to using the compose extension.
Expected behavior
PointAnnotation visibility should not change based on zoom level
Notes / preliminary analysis
Here is my compose extension usage
val shouldDisplayExits = AppDependencies.mapModel.shouldDisplayExits.collectAsState().value
if (shouldDisplayExits) {
val exits = AppDependencies.mapModel.exits.collectAsState()
val points = remember(exits.value) {
if (exits.value == null) {
return@remember emptyList()
} else {
exits.value!!.map { exit -> createPointAnnotationOption(exit) }
}
}
PointAnnotationGroup(
annotations = points,
onClick = { pointAnnotation ->
val data = pointAnnotation.getData()
if (data?.isJsonNull == true || data == null) {
return@PointAnnotationGroup false
}
val jsonObject = data.asJsonObject ?: return@PointAnnotationGroup false
val exitId = jsonObject.get("exitId").asString ?: return@PointAnnotationGroup false
val exitName = jsonObject.get("exitName").asString ?: return@PointAnnotationGroup false
val isExitVerified = jsonObject.get("isExitVerified").asBoolean
lastViewAnnnotationOpen.value = Clock.System.now().toEpochMilliseconds()
AppDependencies.mapModel.openViewAnnotation(
exitId = exitId,
text = exitName,
latitude = pointAnnotation.point.latitude(),
longitude = pointAnnotation.point.longitude(),
profileId = null,
isVerified = isExitVerified,
dropzoneId = null
)
true
}
)
}
private fun createPointAnnotationOption(exit: MapExit): PointAnnotationOptions {
val element = JsonObject()
element.addProperty("exitId", exit._id)
element.addProperty("exitName", exit.name)
element.addProperty("isExitVerified", exit.isExitVerified)
val option = PointAnnotationOptions()
.withPoint(Point.fromLngLat(exit.longitude, exit.latitude))
.withIconImage("blue-pin")
.withData(element)
return option
}
@brendanw from the video, it looks like the somehow the iconAllowOverlap behaves like it was disabled, could you try to manually set it to true?
Please also note there's a known issue regarding applying AnnotationGroup properties, which is fixed in 11.3.0-rc.1 release, please update to the latest version and try again.
I am still seeing the issue with setting iconAllowOverlap=true on the PointAnnotationGroup and using 11.3.0-rc.1
@brendanw could you also try with setting iconIgnorePlacement = true?
I am still seeing the issue with setting iconIgnorePlacement = true on the PointAnnotationGroup and using 11.3.0-rc.1
@brendanw could you please provide a minimal project to reproduce the issue? maybe a patch to our existing compos-app example app would be really helpful.
@pengdev
https://github.com/brendanw/MapboxMemLeak/tree/bw/pointAnnotationIssue
^^ Can reproduce the issue by running the code on the pointAnnotationIssue branch. Just need to populate MAPBOX_SECRET_TOKEN environment variable before running.
I am reusing an older reproducer project for this, but here's the minimal diff for reproducing the issue -> https://github.com/brendanw/MapboxMemLeak/pull/2
With regard to the compose example app, I tried to use the compose-app example app. I populated SDK_REGISTRY_TOKEN and could get the application running, but the map screens all rendered black.
@pengdev I updated the reproduction code at https://github.com/brendanw/MapboxMemLeak/pull/2 to use 11.3.1 and the issue is still present. This is a pretty significant issue and there is another issue that is blocking us from moving away from the compose extension, will this issue be addressed in 11.3.2 ?
@brendanw sorry didn't have time to try your branch earlier, I dropped a comment in your branch and with iconAllowOverlap=true set to the PointAnnotationGroup, I do see the issue being resolved, please let me know if you have other issues.
@pengdev I am an idiot. I have multiple PointAnnotationGroup's for the screen this is on and I neglected to add this field to one of those groups. Thanks for bearing with me and apologies for the false report!