I'm trying to make a layer list with checkboxes to turn on/off layers (TOC).
My layer list need to support KML layer.
I make a very simple example to add and remove kml layer using the online example
However I realise only the initial adding and removing of layer works.
The 2nd time I add the kml layer, it will not be rendered.
To make things easy, I created a jsfiddle @ https://jsfiddle.net/L5pyvezt/1/
In this fiddle, there are 2 buttons on top.
When you click on add, realise that an orange box will be rendered
When you click on remove, the orange box will be removed
When you click on add again, it is expected that the orange box will be re-rendered but alas, it did not.
(Warning: do not add, remove, add, remove too many time, for some unknown reason, although the codes are so minimal, it will crash your browser)
Does anyone have any advice to this strange behavior?
Some extra information:
1) The same code works for feature layer
2) Calling kmllayer.refresh() works