Add and Remove Fetaure layer to WAB

1004
7
02-07-2018 09:51 PM
aishvaryvardhan
New Contributor III

I am adding feature layer to the WAB programatically using "map.addLayer("layername") the layer is successfully getting added to the map but it is also adding to the LayerList widget..
and similiarly while removing i am not able to remove it using map.removeLayer as it prevails in layer list widget.
is there anyway i can resolve it and layer list widget dont get involved.

Any help on this highly appreicated

Thanks

Ash

0 Kudos
7 Replies
XiaodongWang
Esri Contributor

Set 'layerObject._wabProperties.isTemporaryLayer' property to the new layer before it's added to the map.

newLayerObject._wabProperties.isTemporaryLayer = true;

map.addLayer(newLayerObject);

aishvaryvardhan
New Contributor III

HI ,

May i know what do you mean by _wabProperties here ??

0 Kudos
aishvaryvardhan
New Contributor III

Hi,

I tried out this

featurelayerAdd._wabProperties = { isTemporaryLayer: true }; 

way its working fine.

Thanks Wang,

But still i am not able to remove layer using 

this.map.removeLayer(featurelayerAdd);

0 Kudos
XiaodongWang
Esri Contributor

I think that cannot remove the layer is not caused by the LayerList widget or WAB, is there any console errors?

0 Kudos
aishvaryvardhan
New Contributor III

No Wang, no console error ,just un-checking the checkbox and the data prevails on the map

0 Kudos
BrandonPrice
Occasional Contributor

Hey Ash:

What file do you place map.addLayer("layername") in the script? What other programming is needed to make this work?

 

Thanks

Brandon

0 Kudos
BrandonPrice
Occasional Contributor

Hey Xiaodong:

 

What file do you place map.addLayer("layername") in the script? What other programming is needed to make this work?

 

Thanks

Brandon

0 Kudos