How to clear dynamically created feature layer

932
4
Jump to solution
04-24-2018 04:46 AM
SivaramKrishnan2
New Contributor III

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

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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();‍‍‍‍

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
SivaramKrishnan2
New Contributor III

Robert, 

Thanks for the response, I'm adding the layer as a Feature layer only.

please refer the screenshot.

Regards

Siva

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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();‍‍‍‍
SivaramKrishnan2
New Contributor III

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

0 Kudos