jjimenezshaw / Leaflet.Control.Layers.Tree

a Tree Layers Control for Leaflet
https://jjimenezshaw.github.io/Leaflet.Control.Layers.Tree/examples/basic.html
BSD 3-Clause "New" or "Revised" License
146 stars 36 forks source link

base layer attributions being appended to other layers #22

Closed ddrury closed 4 years ago

ddrury commented 4 years ago

Please see attached images, The first shows the map as loaded without using the layer selector (OpenStreetMap) The second shows the position after selecting an Esri layer dump1 dump2 The box outlined in red shows the OpenStreetMap attribution that should have been replaced.

If I remove the OpenStreetMap attribution then everything works OK

Edit: using leaflet 1.6 with the markercluster library

jjimenezshaw commented 4 years ago

Just looking at the images, without any code to test, I can only guess. This plugin does nothing special with the attribution. It is done by Leaflet (or esri plugin) when setting the base map. The comma before "Tiles @ Esri" looks like addAttribution is being called (by Leaflet or Esri). Have you tried with the original Control.Layers from Leaflet? I have done a small example, and it has a strange behavior.

ddrury commented 4 years ago

Solved it, Because I'm creating the layers dynamically, I have eg

layers = [
    L.tileLayer ...,
    L.tileLayer ...
]

but I was setting the base layer from another variable not from one of the layers items