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

19441
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
JuneAcosta
Occasional Contributor III

Mathias,

Does the WAB get installed on my desktop or web server?

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

it's best installed on a desktop machine, not a server, but it does NOT require ArcGIS Desktop or server.  It will require access to ArcGIS Online or portal to get it started.  For tips, check out Tips and Observations for getting Web AppBuilder -  Developer Edition Installed

BrianO_keefe
Occasional Contributor III

I installed ours on our development server. That's where the Flex builder USED to go... (thank the cartographer in the sky that Flex is dying)...

Is there some sort of issue I should expect if ran from a Remote into a server to access the WAB?

0 Kudos
BrianO_keefe
Occasional Contributor III

Mathias,

http://maps.cityoftulsa.org/IOT/ here is the map in question.

Where would I get the layerInfo.id of the layers I want to remove?

Keep in mind, I take one layer and duplicate it multiple times, so I don't what the LAYER removed, just the extra instances of it that I added so I could set visibility settings in AGOL.

0 Kudos
MathiasDOLIDON
New Contributor III

The first place to look at may be your webmap's JSON : http://www.arcgis.com/sharing/content/items/178fc074fc784f5cadd5eba053e73b30/data?f=pjson

Search for "id" and you'll see the ids assigned to map services and feature layers that you added explicitely. For example : IOT_234.

If adressing a layer inside a map service, add _X where X is the layer's id within the service. For example : IOT_234_0

Your particular case has :

IOT_1553 : bridge replacement zoom out

IOT_1553_8354 : bridge replacement zoom in

IOT_1318 : bridge rehabilitation zoom out

IOT_1318_5629 : bridge rehabilitation zoom in

IOT_234 : improve our Tulsa

IOT_234_0 : major street labels

IOT_234_1 : project details

...

IOT_234_7...

Your best bet may be to store the exclude list within a new property inside the layer list widget's config file. Then you patch where I said, checking whether the id belongs to the configured list.

BrianO_keefe
Occasional Contributor III

Spot on!

I (unfortunately) don't have to time to tinker around in the LayerList yet in order to create the exclusionary list. However, I'm considering a custom LayerList widget that lets you pick from your available Layers and remove from LayerList for the future. We (sadly) have to hack a lot of maps like this for a VARIETY of reasons and I keep telling myself that eventually I will have time to get in there and learn the code like I want to.

That part about the JSON was immensely eye-opening. I wish there was better documentation, more easily discoverable and understandable, for those of us with so little time to dedicate to learning this as completely as we would like to. But then I suppose that's what GeoNet is for.

Thanks again Mathias DOLIDON​ that was IMMENSELY satisfying to fix.

0 Kudos
MathiasDOLIDON
New Contributor III

My pleasure, Brian. I'll shoot this last one before leaving the office for today.

I assume you're using the developper edition. In your app, you have the widgets folder, and inside that you find the LayerList folder. In there, there's a config.json. For now it should look like :

{
  "showLegend": true
}

Supposing you want to hide the "zoom in" layers, change it into :

{
  "showLegend": true,
  "hide" : ["IOT_1553_8354", "IOT_1318_5629"]
}

Then you open LayerListView.js. Line 50 looks like :

drawListNode: function(layerInfo, level, toTableNode) {

Change it into :

drawListNode: function(layerInfo, level, toTableNode) {
    if(this.config.hide && this.config.hide.indexOf(layerInfo.id) >= 0) {
        return;
    }

You may be done, and your widget may be reusable. At that stage, if you're happy with it, you can shove it into the client/stemapp/LayerList folder of your web app builder, so your new default LayerList supports ignoring layers if needed.

JuneAcosta
Occasional Contributor III

Mathias,

Thanks for sharing the snippet of code!

I tried to make the same modification to my map to hide the boundary layer in the layer list, but its not working.   Here's what I have.....

http://www.arcgis.com/sharing/content/items/178fc074fc784f5cadd5eba053e73b30/data?f=pjson

config.Json

{

  "showLegend": true,

  "hide" : ["generalPurposeLandbase_3538"]

}

LayerListView.js

postCreate: function() {
      array.forEach(this.operLayerInfos.finalLayerInfos, function(layerInfo) {
        this.drawListNode(layerInfo, 0, this.layerListTable, true);
      }, this);

      array.forEach(this.operLayerInfos.tableInfos, function(layerInfo) {
        this.drawListNode(layerInfo, 0, this.tableListTable, true);
      }, this);
    },

    drawListNode: function(layerInfo, level, toTableNode) {
  if(this.config.hide && this.config.hide.indexOf(layerInfo.id) >= 0) {
  return;
  }
      // layerInfo.getLayerType().then(function(type){
      //  console.log(type + "-------------------------------");
      // });
      var nodeAndSubNode;
0 Kudos
KevinFowler
New Contributor II

I am having the same issue as June.  I've added the code snippets as instructed but can't seem to get it to work.  Does anyone have any ideas why the snippet may not be working?

For anyone having the same issue.  Remember to put the comma at the end of the "hide" snippet in the config.json file.  I copied and pasted the code directly and had a time figuring out the code snippet didn't include the comma.

"showLegend": true,

"hide" : ["PropertyInformation_3054"],

0 Kudos
JuneAcosta
Occasional Contributor III

Kevin,

I had to make the change at the WAB level. - then export the map, again. I can go back and look at the WAB and see where (the directories) I made the changes if you need more specifics. Let me know..

0 Kudos