markusand / mapboxgl-legend

Add a legend to a mapbox-gl map by parsing layer layout & paint expressions.
ISC License
47 stars 11 forks source link

Layers group #23

Open sylvain258 opened 1 month ago

sylvain258 commented 1 month ago

Hello,

Is it possible to group layers ? For example, layers relative to demography together, layers relatives to the nature together etc.

Thank you for your feedback,

Sylvain Becquaert

markusand commented 1 month ago

Panels are created from the layers you define in Mapbox. As long as there are different layers, it's not possible to group them right now.

That said, there's the option to toggle multiple layers with a single toggler. Hope this helps.

const legend = new LegendControl({
  layers: {
    lakes: true,
    rivers: {
      toggler: ['rivers', 'lakes'],
    },
  },
})