mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

MapboxMap.removeAnnotations() doesn't remove markers

Open vfaSonnt opened this issue 10 years ago • 4 comments

I just upgrade to 4.0.0 and this bug happen. Method removeAnnotations() doesn't work anymore. But removeMarker(Marker) still work. I check on both android OS under 5.0 and above 5.0. Both my project and Mapbox Example Source.

vfaSonnt avatar Mar 31 '16 07:03 vfaSonnt

@vfaSonnt thank you for brining this to our attention. I was able to reproduce this initial screen: device-2016-03-31-102921

mapboxMap.removeAnnotations is being called when I press the garbage bin in the options menu:

device-2016-03-31-102946

Not all the markers were removed but some are. I'm guessing that the ids passed to core are not correct.

tobrun avatar Mar 31 '16 08:03 tobrun

When adding marker, I'm seeing these ids:

03-31 10:39:03.683 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: marker added with 6
03-31 10:39:06.421 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: marker added with 10
03-31 10:39:09.271 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: marker added with 11

When I inspect the first added marker with id 6, I'm seeing it has a value of 9. When removing I'm seeing the following ids passed to core:

03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 0
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 1
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 2
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 3
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 4
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 5
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 6
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 10
03-31 10:39:21.524 15756-15756/com.mapbox.mapboxsdk.testapp V/TAG: 11

This is a regression from the fix in https://github.com/mapbox/mapbox-gl-native/issues/4393. Here you can see the issue in action, you should be able to see that the marker is multiple times added / removed because DID_FINISH_RENDERING_MAP_FULLY_RENDERED is called multiple times.

tobrun avatar Mar 31 '16 08:03 tobrun

I found a fix for this by ensuring it's only called once without changing the event type, So this won't impact the previous fix in #4393.

tobrun avatar Mar 31 '16 08:03 tobrun

Thank you very much! I checked, it is OK. Now I am waiting for next release. =)

vfaSonnt avatar Mar 31 '16 09:03 vfaSonnt