ipyleaflet icon indicating copy to clipboard operation
ipyleaflet copied to clipboard

"visible" attribute is misleading and could be deprecated

Open mangecoeur opened this issue 7 months ago • 0 comments

The "visible" attribute of Layers gives users the idea that there is a "visible" toggle in Leaflet that allows them to load data into the browser and toggle visibility on and off.

But this is not the case, instead some (but not all) layers special case the visible attribute and don't add the layer data to leaflet if it's false. This means that users are sending data to the browser that then gets discarded, rather than "efficiently" preparing layers in the browser and just toggling their rendering. Furthermore, some layers just don't implement this case leading to confusion (e.g. #1244 ), and toggling the visible attribute on an already created layer doesn't always work.

The simplest solution would be to document+deprecate the visible attr - because (at least at a glance) Leaflet doesn't support visibility toggling at all, only adding or not the data to the map.

mangecoeur avatar Apr 21 '25 10:04 mangecoeur