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.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.