Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Loop to add and remove markers,markers are not visible #4778

Closed

Description

@echo326

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

Activity

  1. added
    Android
    on Apr 21, 2016
  2. Schumi09 commented on Apr 21, 2016

    @Schumi09

    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)

  3. Schumi09 commented on May 11, 2016

    @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.

  4. tobrun commented on Jun 21, 2016

    @tobrun
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions