Raruto / leaflet-kmz

A KMZ file loader for Leaflet Maps
GNU General Public License v3.0
48 stars 27 forks source link

Prevent auto loading KMZ layers on map until user clicks on related L.Control.Layer checkbox #41

Open kg6uyz opened 1 month ago

kg6uyz commented 1 month ago

Is there a way to load the list of KMZ's but not auto load the KMZ's onto the map until a user clicks one of the check mark boxes?

Raruto commented 1 month ago

L.Control.Layers follows the state of the level:

https://github.com/Raruto/leaflet-kmz/blob/ed43fe930ddd93267278ad0c734ce699ecdd607a/examples/leaflet-kmz.html#L50

  1. You can remove them individually as soon as they are loaded (eg. e.layer.remove()):

https://github.com/Raruto/leaflet-kmz/blob/ed43fe930ddd93267278ad0c734ce699ecdd607a/examples/leaflet-kmz.html#L52-L55

  1. or, simply avoid adding the parent layer to the map (ie. kmz.addTo(map)):

https://github.com/Raruto/leaflet-kmz/blob/ed43fe930ddd93267278ad0c734ce699ecdd607a/examples/leaflet-kmz.html#L50