Closed glathoud closed 8 years ago
Thanks for this @glathoud. I feel like our current solution to #27 is a bit of a hack currently, so I would prefer to fix that. That is, I would prefer not to call _handleLoading
on baselayerchange
as we do now. I assumed that would cause problems but haven't run into them myself.
Can you provide a minimal example of this going wrong (eg via jsfiddle or jsbin)?
Sure: http://jsbin.com/sikageyiva/edit?html,output
Just click on the control on the top-right of the map and switch to "layerGroup".
Thanks @glathoud. I think 21a3e85c should cover it, mind giving it a try?
Thanks @ebrelsford the fix is working fine.
Detail: the fix could be recursive.
Fair enough. Fixed, let me know if there are any other issues.
It's running fine at the moment, thanks.
Context: using a
L.control.layers
instance and aLayerGroup
.Use case:
when the user clicks on the layer control, and switches to
b
, the loading indicator appears (correct) but stays forever (bug).The issue seems to be caused by:
so that it is expected that the baselayer
some_layergroup
also fires"load"
which never happens.Tentative fixes
I tried this modification:
...but this revives issue 27.
I also tried to protect the
layer.on(...)
calls, but to no avail.Current solution
Use a
FeatureGroup
that is extended to support the"loading"
and"load"
events:Leaflet.FeatureGroup.LoadEvents
.Remark
I honestly don't know whether this issue is fixable within
Leaflet.loading
, especially from a design point of view, or whether the issue must be fixed outside of it, e.g. with theLeaflet.FeatureGroup.LoadEvents
plugin.