I am creating dynamic feature class in Widget A and added the layer in the map successfully . When I open Widget B, I want to clear the dynamic feature class which was created in Widget A. How to Proceed?
Thanks & Regards
So in your code you should assign a unique id to the FeatureLayer.
this.dynamicFL.id = 'myDynamicFL';
and then in your widget B you get that layer using
this.dynamicFL = this.map.getLayer(this.map.graphicsLayerIds.indexOf('myDynamicFL'));this.dynamicFL.clear();
That really depends on how you created the dynamic feature class in Widget A. If you added a graphicsLayer or a FeatureLayer, or added Graphics to the maps Graphics. A FeatureLayer has a clear method and so does all GraphicsLayers.
Thanks for the response, I'm adding the layer as a Feature layer only.
please refer the screenshot.
Thank you so much for your response, it worked for me after doing some small changes.
this.dynamicFL = this.map.getLayer(this.map.graphicsLayerIds.indexOf('myDynamicFL'));//this will return the index only not the layer so dynamicFL becomes undefined.
so i modified the code to get the layer of that index
Retrieving data ...