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

Loop to add and remove markers,markers are not visible

Open echo326 opened this issue 10 years ago • 4 comments

When I was in the loop to add remove markers more than 25 times, Can't see any markers on the mapview

List<Marker> markers = mMapboxMap.getMarkers();
for (int i = 0; i < markers.size(); i++) {
     markers.get(i).getIcon().getBitmap().recycle();
}
mMapboxMap.removeAnnotations();
mMapboxMap.addMarkers(markerList);

Platform: samsung s5 **Mapbox SDK version:**4.0.0-beta.2

Steps to trigger behavior

  1. mMapboxMap.removeAnnotations();
  2. mMapboxMap.addMarkers(markerList);
  3. mMapboxMap.removeAnnotations();
  4. mMapboxMap.addMarkers(markerList);

After 25 times or more,Markers are not visible anymore.

Expected behavior

Markers should be visible

screenshot_2016-04-21-20-51-00 1

Actual behavior

Markers are not visible

screenshot_2016-04-21-16-55-45 1

screenshot_2016-04-21-20-57-07 1

echo326 avatar Apr 21 '16 13:04 echo326

Hi there, I'm facing similiar issues for a while but thought it was related to the poor performance of my current phone (Sony Xperie P, Android 4.4.2 CM). My issue is not exactly the same but for me some certain markers are also not drawn after some iterations. It is possible that my experiences are a new issue but i want to share my experiences here first.

So, this occurs on 4.0.0-beta1 and 2 (didn't use the final because of the Marker issue of removeAnnotations()) and I have just tried the 4.1.0 Snapshot:

For some amount of time everything is working fine when I clear some annotations using removeAnnotations(List) and creating new annotation lists as visualization attribute of a certain class. So unlike the OP, its running fine for some minutes in the normal onLocationChangedEvent. However, at a random point some (new, I do not store and re-add them like OP) Markers are not added anymore. Part of the annotations as visuals for my class are among other things two Markers. All markers that use Icons that are set up at the MainActivity's onCreate and set of a class 'Landmark' are always reused for the visualizations and do still get added to the map. However, those that are newly created which means getting the PNG file from Resources and creating an Icon via IconFactory are not. I had the same behaviour when I did the same approach for a Marker that displays the current user position. However, after making it using an Icon that is set up in onCreate this position marker remains being drawn, while those others are not.

In summary, it does not seem to be related to the removing and adding of markers, but rather to the newly creating of Icons.

My project code is located at https://github.com/Schumi09/WayTo-Navigation (Let me know if you need a more detailed description of my experiences)

Schumi09 avatar Apr 21 '16 18:04 Schumi09

My posted experiences are related to #4189 so it'll be fixed within #4207. However, it does not explain the issues during runtime which is also part of #4189 that @tobrun has closed. The OP here does not create new bitmaps in every iteration.

Schumi09 avatar May 11 '16 13:05 Schumi09

Hi, i'm facing similiar issues, after update 4.1.0-SNAPSHOT, previously not problem with 4.1.0-SNAPSHOT, how to fixed this?. Thanks.

ghost avatar May 13 '16 01:05 ghost

This should be resolved with the introduction of View Markers in 4.1.0. Feel free to reach out to ask more questions! Closing as non actionable.

tobrun avatar Jun 21 '16 14:06 tobrun