3

Is it possible create a cluster source with tiles?

With geojson works perfectly but I would like to work with a tile source.

map.on('load', function () {

   // add source
   map.addSource('geosjonsource', {
    'type': 'geojson',
    'data': 'https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson',
    'cluster': true,
    'clusterMaxZoom': 14,
    'clusterRadius': 50,
   });

   // add layer
   map.addLayer({
     'id': 'prueba',
     'source': 'geosjonsource',
     'type': 'circle',
     'filter': ['has', 'point_count'],
     'paint': {
       'circle-color': ['step', ['get', 'point_count'], '#51bbd6', 100, '#f1f075', 750, '#f28cb1' ],
       'circle-radius': ['step', ['get', 'point_count'], 20, 100, 30, 750, 40 ]
      },
      'layout': {}
   });
}

I've created a vector tile server to render pbf sources and I would like work with this source:

map.addSource('vectorsource', {
    'type': 'vector',
    'tiles': ['http://192.168.240.71:8090/tile/earthquakes/{z}/{x}/{y}.pbf'],
    'cluster': true,
    'clusterMaxZoom': 14,
    'clusterRadius': 50,
});
3

1 Answer 1

2

It would appear that for now, the answer is just no, the client side clustering can't use a vector tile source:

https://github.com/mapbox/mapbox-gl-js/issues/5856#issuecomment-719928884

You could cluster in postgis or tippecanoe and import that layer into studio-

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.