Problem solved,
if (this.map.getLayer (layerID)) this.map.removeLayer (this.map.getLayer (layerID));
where layerID is the given layer.id when the layer is created, e.g., could be the same as lyr.name in your case.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.