-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GoogleMap]: Markers aren't cleared out when provided backing field changes #456
Comments
If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.@bmc08gt Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
Hi @bmc08gt , Your approach is correct. We have this sample here that provides a snippet showcasing how to update individual markers. Maybe a question on the snippet above: are you sure the keys are unique on each update? They should trigger the recomposition. |
@bmc08gt I believe the most significant problem is your usage of rememberMarkerState(). You never actually update the MarkerState location. The rememberMarkerState() position parameter is only used for state initialization, not state updates. |
Im creating entirely new markers with new coordinates (each with their own MarkerState). The markers were being reused even though I was reiterating through an entirely new list with new unique identifiers. They isn't always going to be the same amount of markers every time being rendered in the map (list is filtered results). |
I am having the same issue. Basically I move the map with a new set of markers to display. At some point (after a couple of moves) the markers don't update anymore. They're still showing in the old position, even though the Map was recomposed with the new positions and I can see the marker contents were recomposed as well. Edit: they key (ID) given to the MarkerComposable is unique every time, per every distinct marker. |
I have the same issue. I try to display one marker at a time. When clicking on the map, I attempt to update both the marker's position and its displayed text. While the position updates successfully, the text remains unchanged. Code example:
` I tried to migrate to MarkerComposable from solution with Bitmap descriptor. Unfortunately, I can no longer use the previous solution because, after a library update (not precisely sure which update), it results in constant flickering of the Marker, and it makes impossible to process click events on the marker. |
@bmc08gt in your original example, do you reuse the List object and simply clear and completely repopulate it when you send updates? If so, it may help to use a completely new List object for your "entirely new list". What I believe is happening: Compose tries to align the old contents of the list with the new contents, and trying to reuse whatever it composed before, in particular remembered MarkerState. Because you never tell Compose to update the marker positions, you get new Marker contents, but old positions. If it does not work despite using a new List object every time, additionally wrap your forEach loop with the new List object as a key:
|
Environment details
Kotlin 1.9.10
AGP 8.3.0-alpha11
Maps Compose 4.1.1
Compose Plugin 1.5.10
Steps to reproduce
MarkerComposables
from a List provided by a ViewModel State or other data sourceCode example
However by creating my own
MutableState
for the List, initialized asemptyList()
I'm able to have the map clear and redraw the new markers.Stack trace
N/A
Following these steps will guarantee the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: