How am I supposed to update markers in @capacitor/google-maps #7500
Unanswered
frederikheld
asked this question in
Q&A
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm really confused about how to use this plugin properly. Honest question: how am I supposed to update marker visibility?
My use case is live search of locations. Each location has a marker and the plugin is luckily performant enough to draw 200+ markers quickly (even on web). But I'm struggling to update the markers as the filter criteria change.
Currently, with each filter update I'm deleting all markers and redrawing only those that match the filter. This works on web but has issues on Android where the markers aren't properly deleted. Probably a race condition because the user keeps typing while the map is updated but I am struggling to debug it.
My issue is that I have to keep track of the marker ids that have been returned by
createMarker
in order to be able to delete them. I also have to keep track of the mapping between a location and it's marker. And I can only delete a marker if I know its id. So if this solution has a hiccup, I will end up with markers that can never be deleted because the reference was lost.Question 1: how can I delete all markers without providing specific marker id's? Is there something like a
deleteAllMarkers()
function that just deletes all markers on the map?Question 2: is there an easier way to keep track of markers an locations than the one I am using?
In other maps libraries instead of deleting and re-drawing all markers, I instead would update the visibility whenever the filter criteria change. But in this plugin, I have no way to get the marker by it's id, so I can't manipulate it later.
Question 3: is it possible to change the visibility (and other properties) of a marker that is already on the map?
Can you please provide me with examples on how to use this plugin properly? Unfortunately the docs
are borderline uselesshave much room for improvement. :-(Beta Was this translation helpful? Give feedback.
All reactions