Mapbox-gl-native: Auto-clustering on SymbolLayer cannot be switched off

Created on 12 Jul 2017  路  1Comment  路  Source: mapbox/mapbox-gl-native

I created an example Android app with MapBox, where I have 3 SymbolLayers with GeoJsonSources.
Each layer has a different icon ("NEW", red, and blue marker), and on each layer I add 500 points randomly in the US.
Zooming in and out makes some icons appear/disappear. Apparently, there is some sort of auto-clustering going on.
This is how it looks like when you zoom out a lot:

This is how I initialized the layers:

private void initLayer(String prefix, @DrawableRes int icon) {
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), icon);
    this.mapboxMap.addImage(prefix + "-marker-image", bitmap);
    SymbolLayer markers = new SymbolLayer(prefix + "-marker-layer", prefix + "-marker-source")
                .withProperties(PropertyFactory.iconImage(prefix + "-marker-image"));
    switch (prefix) {
        case "new":
            this.mapboxMap.addLayer(markers);
            break;
        case "red":
            this.mapboxMap.addLayerBelow(markers, "new-marker-layer");
            break;
        case "blue":
            this.mapboxMap.addLayerBelow(markers, "red-marker-layer");
            break;
    }
    FeatureCollection featureCollection = FeatureCollection.fromFeatures(new ArrayList<Feature>());
    Source geoJsonSource = new GeoJsonSource(prefix + "-marker-source", featureCollection);
    this.mapboxMap.addSource(geoJsonSource);
}

This is what I tried, but what doesn't work:

Source geoJsonSource = new GeoJsonSource(prefix + "-marker-source", featureCollection, 
                new GeoJsonOptions().withCluster(false));

Is there a different way to switch this clustering off?
Is it even intended to be there?

Platform: Android 7.1.1, OnePlus 3T
Mapbox SDK version: 5.1.0

Steps to trigger behavior

  1. Add a lot of markers as points to a GeoJsonSource of a SymbolLayer.
  2. Zoom in and out.

Expected behavior

All points that I added are visible all the time.

Actual behavior

Only few points are visible when zoomed out.

Android

Most helpful comment

By default, symbol layers are tailored for text labeling, where collisions are undesired. To allow symbol collisions, set the iconAllowOverlap and iconIgnorePlacement properties of your layer to true.

>All comments

By default, symbol layers are tailored for text labeling, where collisions are undesired. To allow symbol collisions, set the iconAllowOverlap and iconIgnorePlacement properties of your layer to true.

Was this page helpful?
0 / 5 - 0 ratings