I have a quite complex webapp with a lot of data on a map. Except the basemap, the data of each layers are coming from AJAX queries, witch's responses are formatted as GeoJSON object -- up to this works fine. (Each of this responses -- so each GeoJSON object -- can be more than 1 Mb.)
With checkboxes I'd like to show or hide the datasets.
I prepare each layer in this way: var layer_1 = L.geoJSON(null, { style: style_1, pane: "pane_1" }).addTo(myMap);
.
I can add data: layer_1.addData(data_1.responseJSON);
.
If I'd like to hide this dataset, is it possible somehow to remove only this dataset from layer_1
(as "opposite" of addData()
), or the only way is to myMap.removeLayer(layer_1);
, and then create the layer again?
LayerGroup
, see leafletjs.com/reference-1.7.1.html#layergroupL.GeoJSON
instances, one per dataset.