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

MapBox SymbolLayer Items #10517

Closed
nikiizvorski opened this issue Nov 21, 2017 · 12 comments
Closed

MapBox SymbolLayer Items #10517

nikiizvorski opened this issue Nov 21, 2017 · 12 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@nikiizvorski
Copy link

Platform: Android
Mapbox SDK version: 5.2.0-beta5

Steps to trigger behavior

  1. Loading Multiple Objects - 500
  2. Using SymbolLayer
  3. Apply all of them as Bitmaps and add to the layers

Expected behavior

  • Is there a better way to load multiple objects to the map. If so please share?

  • There is currently no example or good way to show that many objects to the map.

Actual behavior

  • Slowing down quit a lot since the bitmaps are very expensive

Thanks you

@tobrun
Copy link
Member

tobrun commented Nov 21, 2017

@nikiizvorski would you be able share a bit of code?
What do you mean with multiple objects?
Thank you for reaching out and reporting your issue!

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Nov 21, 2017
@nikiizvorski
Copy link
Author

`Well imagine you need to add 500 pictures to the map. What would be your way to add them to a SymbolLayer since i haven't found a way since it supports only Bitmaps and there is no device that runs that configuration for me.

FeatureCollection featureCollection = FeatureCollection.fromFeatures(markerCoordinates);
Source geoJsonSource = new GeoJsonSource("marker-source", featureCollection, new GeoJsonOptions());

        mapboxMap.addSource(geoJsonSource);

        SymbolLayer markers = new SymbolLayer("marker-layer", "marker-source");
      

        mapboxMap.addLayer(markers);

        // Add the selected marker source and layer
        FeatureCollection emptySource = FeatureCollection.fromFeatures(new Feature[]{});
        Source selectedMarkerSource = new GeoJsonSource("selected-marker", emptySource);
        mapboxMap.addSource(selectedMarkerSource);

        SymbolLayer selectedMarker = new SymbolLayer("selected-marker-layer", "selected-marker");
        mapboxMap.addLayer(selectedMarker);
        mapboxMap.setOnMapClickListener(this);

       And after you add the images to the layer with Glide.load.simpleTarget.Bitmap and add it to the current id.

`

@tobrun
Copy link
Member

tobrun commented Nov 21, 2017

@nikiizvorski

Here is an adapted example of our SymbolGenerator activity. It reads out 500 points from a geojson file, generates a TextView and converts that to a Bitmap. You store that Bitmap in a Map<String, Bitmap>and afterwards call into MapboxMap#addImages (this is way faster as calling addImage separately as we can batch and background some work).

ezgif com-video-to-gif 5

I need to add that 500 bitmaps might be setting the expectations a bit high. Since bitmap operations are costly, it can result in halting the map momentary, though this wasn't explicitly noticeable in gif above:

ezgif com-video-to-gif 8

@nikiizvorski
Copy link
Author

Well thats something completely different. Can you please try to do some images from URL and convert them back to bitmaps with Glide on a small device like S5 with 32 VM. Really want to see how is that possible. Seems i cannot find a efficient way. Since doing a TextView as a bitmap is not heavy operation and you are reusing the Bitmap in the pool this shouldn't block it for you i don't know why is stuck for you like that as the example on the gif.

Thanks

@nikiizvorski
Copy link
Author

nikiizvorski commented Nov 21, 2017

Trying that example on mine crash the JNI directly and doesn't want to go forward with the same activity. I understand where you are going with the HashMap but please check my remark on the implementation we are trying to achieve. Since the example thats put is not the exact situation.

@AlexLiuSheng
Copy link

Is there any solution for multiple object,I am facing same problem,Map is Slow when i added many SymbolLayer into map

@nikiizvorski
Copy link
Author

You shouldn't add many Symbol Layers use one. And avoid putting much on the client if your implementation doesn't specifically require that. I think there is a better way to do it on a server side. As other people did. Other than that use one Symbol Layer.

@AlexLiuSheng
Copy link

Thank you for you response, The problem is how can I set different bitmap in different location when using one symbol layer

@AlexLiuSheng
Copy link

Okay,Thank you so much

@nikiizvorski
Copy link
Author

You can create even a custom view as they did but you don't need. The HashMap Implementation of mapbox.addImages() as a big one can improve a bit. But the difference between addImage on a single element is not big on my tests.

@tobrun
Copy link
Member

tobrun commented Nov 22, 2017

Can you please try to do some images from URL and convert them back to bitmaps with Glide on a small device like S5 with 32 VM

Would happy run some additional tests but I don't have a datasets with any images url at hand.

I understand where you are going with the HashMap but please check my remark on the implementation we are trying to achieve.

I don't see any problems with converting your current implementation into what I'm proposing: create an asynctask, get all the images you want with glide synchronously and put that into a hashmap. Additionally there are other ways of preloading data or using something as a CustomSource to have more fin grained control over what is displayed when.

@nikiizvorski it doesn't seem you are actively looking into the applying any of my suggestions. You remarks aren't constructive and your expectations are off (have you tried loading in 500 images on the main thread in ImageViews in a scrollable container? I don't think performance will be great for that either). I ticketed out #10526 as follow up work. Going to close this issue in favour of that one.

@AlexLiuSheng I'm not sure about your use-case but why would you like to add many symbolLayers to your map? In most cases 1 will be sufficient with the correct configuration.

@tobrun tobrun closed this as completed Nov 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

3 participants