baselayerchange event not firing on first base map change

331 views
Skip to first unread message

John Kerfoot

unread,
Feb 6, 2014, 9:25:49 PM2/6/14
to leafl...@googlegroups.com
I set up a layer control for my Leaflet map to allow the user to switch between 2 base maps.  I'm trying to use the 'baselayerchange' event to switch the colors of some GeoJSON layers depending on which base map is visible.

It seems that the 'baselayerchange' event is not firing the first time I switch to a new base map via the layer control.  All subsequent base map changes do fire the 'baselayerchange' event.  

Why is the first base map change not firing the event?

JSFiddle:

Thanks,
John

John Kerfoot

unread,
Feb 7, 2014, 8:14:38 AM2/7/14
to leafl...@googlegroups.com
Just want to update the purpose of the fiddle.  Change the base layer at least twice using the base layer control in the upper right.  On the first change, you'll see no text displayed above the map.  All subsequent base layer changes will display the name of the layer changed to.

John

Daniele Strigaro

unread,
May 12, 2016, 11:25:41 AM5/12/16
to Leaflet
I know this is an old discussion. 
Anyway, I have the same problem.
Have you found a method to resolve it?

Thanks
Daniele
Reply all
Reply to author
Forward
0 new messages