Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Leaflet LayerGroup - Mapbox GL JS Equivalent

Does anybody know of an equivalent to the Leaflet L.layerGroup in Mapbox GL JS? I can do this in leaflet:

var layerGroup = L.layerGroup().addTo(map);

And then if I want to add, say, a marker to the layer group, I can do

L.marker([50.5, 30.5]).addTo(layerGroup);

The functionality I am really trying to get is the ability to remove and add back these layers. In leaflet you can do

// remove the layer from the map
map.removeLayer(layerGroup)

// re-add the layer to the map
layerGroup.addTo(map)

// clear all layers without removing from the map
layerGroup.clearLayers()

However in Mapbox GL JS I haven't found a functionality or a plugin that does something similar to this. When you want to add something to the map in Mapbox, you can do .addTo(map), so it seems to me there is probably a feature where you can create a layer group and do .addTo(layerGroup).

It might not be exactly how I envision it here, but right now I have nothing.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!