Can I remove layers from my LayerList in a WAB created map?

19326
52
Jump to solution
03-16-2015 01:31 PM
BrianO_keefe
Occasional Contributor III

I have had to replicate, duplicate, and masticate (it means chew, people) several layers on a web map in order to get them to show up like the clients want them to be shown.

However, now I have a LayerList that is obnoxious with repetitive layers.

Can I remove layers from the LayerList?

And how?

Tags (2)
52 Replies
deleted-user-0W0-oLHxDjCX
New Contributor III

I agree with you Robert Scheitlin, GISP . I only would like to know where is it possible to reload the layers on LayerListWidget (because it loads only one time). Best regards.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ezequias,

   The onOpen method gets called each time the widget is made visible.

deleted-user-0W0-oLHxDjCX
New Contributor III

Thanks a lot. That's what I really need. Everyone can find it at BaseWidgetPanel.js.

My best regards.

Ezequias

0 Kudos
deleted-user-0W0-oLHxDjCX
New Contributor III

Thank you Robert Scheitlin, GISP

I am focused on removing layers and adding it again (like a filter). I am using the layerlistView.destroy() method but even the layers were hidden on LayerListWidget this action doesn't reflect on the map.

I also tried to run window.layerlistView.postCreate() but without any success.

Another question I would like to know if there is some method that is executed right in the loading of the map (importing the application map set) because I couldn't find it out.

I also noted that some methods like refresh and load are not public on the dijit api.

Could you give me some directions so i can find out a plausible solution to this case.

My best regards

Ezequias Rocha

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ezequias,

   Are you saying that if you use map.removeLayer(x); that the layer list widget does not update automatically?

0 Kudos
deleted-user-0W0-oLHxDjCX
New Contributor III

I am trying to execute this method this way window.layerInfo.map.removeLayer(window.layerInfo.map.getLayer("The layer name")) but it does not work.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ezequias,

  If you are using that code in a widget then you should just use

this.map.removeLayer(this.map.getLayer("the layer name"));

0 Kudos
deleted-user-0W0-oLHxDjCX
New Contributor III

Sorry but I am getting this error:

Uncaught TypeError: this.map.getLayer is not a function(…)(anonymous function)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

If you are in a widget then you will have access to this.map unless you are in a call back function that is out of scope and you did not use lag.hitch.

0 Kudos
deleted-user-0W0-oLHxDjCX
New Contributor III

I am calling the method from web browser console.

0 Kudos