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

[Android] Addmarkers() with markerview ?

Open benjisora opened this issue 10 years ago • 6 comments

Hello there,

I'm using MapBox in an Android app to render a lot of markers on a map, and to do so, I was creating a List of MarkerOption, and I was using the 'addmarkers' function then. By using 'addmarker' and adding them one by one, it weirdly takes way to long, as explained (and solved) in #5390

The problem is, I have to add a custom icon to each of them, and it seems like when I do so, some markers disappear kinda like seen in #3379, and I end up with a memory leak if I refresh several times even though I use "removeAnnotations" to make sure it cleans the map when I refresh the data. (I think my code needs some correcting, but still, the disappearance of the markers I had before when not adding a custom icon is a bit problematic...)

I saw that MapBox 4.1.0 introduced the markerviews, but I have troubles adding them like I previously did with simple markers (in a list and then using addmarkers). Is there any way to add multiple markerview at once on a map ?

Thank you.

benjisora avatar Jul 01 '16 07:07 benjisora

Backstory why we currently aren't exposing the following signature:

addMarkers(@NonNull List<? extends BaseMarkerViewOptions> markerOptionsList)

Is because it collides with:

addMarkers(@NonNull List<? extends BaseMarkerOptions> markerOptionsList)

At this point I only think exposing a different signature would resolve this:

addMarkerViews(@NonNull List<? extends BaseMarkerViewOptions> markerOptionsList)

tobrun avatar Jul 04 '16 13:07 tobrun

I also have this problem, when to solve this BUG

shiyuankao avatar Jul 07 '16 03:07 shiyuankao

I follow this issue carefully, because currently when i use MarkerView, I have performance problems when I use about 100 MarkerView.

SylvainHocq avatar Aug 17 '16 13:08 SylvainHocq

@SylvainHocq we are aware of the performance issues with MarkerView. MarkerViews are Android SDK View objects synchronised above a SurfaceView. They are extremely flexible when it comes to functionality but are limited in performance. We hope to solve this use-case some day with Marker View clustering. GL based markers on the other hand scale much better, they are drawn as part of our gl rendering but they do not expose all the basic functionality yet.

tobrun avatar Aug 18 '16 20:08 tobrun

@tobrun There's a problem with GL Markers if mass refresh icons every seconds there will be a memory corruptions resulting in all markers disappearing.

Mandrakia avatar Sep 05 '16 23:09 Mandrakia

We now include .addMarkerViews() in the SDK for easier adding of markers.

@Mandrakia You should only remove and re-add markers as a last resort. It's much better just to update their location, icon, etc.

Closing ticket since nothing else seems to be actionable here. If anyone has questions, feel free to reach out through our contact page and I'l be happy to help.

cammace avatar Nov 09 '16 22:11 cammace