Closed sana-20 closed 2 years ago
Hi,
You should use MapView.removeMarker(marker)
api, not removeView
:
private fun removeAnimMarker() {
mapView.removeMarker(animMarker)
}
Hi @peterLaurence.
It does not work though I changed the code as you answered. Not only does the marker still remain, but it is not anchored in the center position that I set. (4096, 4096) It moved whenever the map's zoom level or camera position changed.
Hi @sana-20 ,
I can't reproduce your issue. I've updated the demo of MapView to showcase how to remove a marker. Inside the "Map and Markers demo", you'll see a red circular marker which you can remove/add using the button at the bottom.
See the code is in MapMarkersFragment
of the demo.
I suggest that you make a github repo reproducing your issue.
Hi @peterLaurence,
I really appreciate your help. Adding and removing a marker works perfectly without an animation. But the tricky part is when I added an animation to a marker. Even though I clicked a remove button, it does not disappear. It looks like gone at glance, but when you changed the zoom level, you can see a marker still remaining.
See the code here.
Indeed, with an animation set, I could reproduce.
I managed to solve the issue by invoking clearAnimation()
on the marker right before removing it. So for your use case:
private fun removeAnimMarker() {
animMarker?.clearAnimation()
mapView.removeMarker(animMarker)
}
You can use this fix in the meantime. I'll add clearAnimation
in the MapView.removeMarker
api.
Hi Peter.
I added a custom marker with an animation but it is not removed from the mapview.
This method is called when the grey star button is clicked.
This method is called when the yellow star button clicked again.
Do you have any clue to solve this?
https://user-images.githubusercontent.com/66289794/129162353-f67fec1a-8d86-45b8-be34-45749908c34e.mp4