Hi
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
Siva
Solved! Go to Solution.
Siva,
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();
Sivaram,
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.
Robert,
Thanks for the response, I'm adding the layer as a Feature layer only.
please refer the screenshot.
Regards
Siva
Siva,
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();
Robert
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
Thanks & Regards
Siva