markusand / mapboxgl-legend

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

Layers group #23

Open sylvain258 opened 3 months ago

sylvain258 commented 3 months 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 3 months 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'],
    },
  },
})