Re: [Leaflet] remove layer

17 views
Skip to first unread message

Mark Lawton

unread,
Oct 5, 2022, 3:18:31 AM10/5/22
to leafl...@googlegroups.com
It looks like you are setting the array to [ ]

Be careful that you are not destroying access to your markers at the want time.  

Sent from my iPhone

On Oct 5, 2022, at 12:08 AM, Jm Dozier <jd020...@gmail.com> wrote:


Hello everyone

For my little project, I've created a map with 100 markers.

Each marker must be displayable / or not visible individually according to its boolean parameters thanks to five checkboxes.

I try to go through the layers by creating as many layers as markers.


Lmarker.push(marker);
LayerMarker = new L.featureGroup(Lmarker);
LayerMarker.addTo(Rmap); Layers.push(LayerMarker);
Lmarker = [];

So I got an array of 100 records for Layers
Then I was thinking of doing: Rcarte.removeLayer(Layers[10])

But it didn't work.
Does anyone have a small track to advise me for my problem: each layer or each marker must be individualized.

With many thanks

Jean Michel

--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leaflet-js/cdfc6a5d-96cf-49d4-a276-8f3caa94ee3dn%40googlegroups.com.

Jm d

unread,
Oct 6, 2022, 3:13:34 AM10/6/22
to leafl...@googlegroups.com
Hello everyone,
I've founded a solution

Layers = new Array();
.......
boucle = 0;
.......
Layers.push(marqueur);
map.addLayer(Layers[boucle]);
boucle++;
...................
And it'easy  to do that : map.removeLayer(Layers[...]);

Each marker = one layer

Jean Michel

Reply all
Reply to author
Forward
0 new messages