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.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.