Leaflet add/remove legends with layer selection

可紊 提交于 2019-12-06 16:00:06

Your code needed just a couple of changes. Working fiddle: http://jsfiddle.net/T8DHb/8/

When you change the base layer, the even fired is not 'overlayadd', it is 'baselayerchange':

map.on('baselayerchange', function (eventLayer) {

You should only add to map the layer which you want to show for the default base layer. I added PermaFrost.

Also, you should only add to the map the legend which you want to go with the default base layer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!