Hide a layer in the layer list

2103
7
Jump to solution
05-26-2017 01:55 PM
TracySchloss
Frequent Contributor

I have a layer that I want to be present in my map, but I don't want the user to be able to turn it on or off.  I'm using just as a mechanism to allow urlParameters in my Basic Viewer.

I can turn it off in the Legend, but it is still in the list of layers. 

0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

Tracy,

Its a bit of a hack but you could hide the layer in the layer list with custom css.  In the example below we hide the first item in the layer list widget. To test in your app just replace the value 1 in the css below with the number of your layer in the list. Note that I haven't tested this extensively so there could be some unexpected behavior but its worth exploring.

.esriList > li:nth-child(1) {
    display: none;
}

View solution in original post

7 Replies
KellyGerrow
Esri Frequent Contributor

Hi Tracy,

Could the layer be added as part of the basemap?

Choose basemap—ArcGIS Online Help | ArcGIS 

If not, can you give a little more information about the purpose of the layer and what it is used for in the app?

-Kelly

https://community.esri.com/groups/cats?sr=search&searchId=5c8efe1a-7be8-4f25-90a7-e07e830e2daf&searc...

0 Kudos
TracySchloss
Frequent Contributor

It's a feature layer, not on the list of types you can add to your basemap.

Here's my scenario.  I have a layer of streams and a layer of lakes.  They both have water ids, and the user wants to be able to use a urlParameter argument, so they can zoom to a particular body of water.  The water body ids were defined such that the ids for the start at 7000, making their numbering scheme distinct from the ids on the streams.

It makes sense that should only have one layer to search on as an incoming argument.  I created a polyline layer out the lakes and merged it into a copy of the streams to make a query layer.  Then the user can specify a water body ID, which searches against this query layer and zooms into either a lake or a stream.  The query layer only has the water body ID on it, the attributes aren't the same for the rivers and streams.  I needed to leave these each in their own layer for the popup configuration. 

I don't want to see the query layer, I just need it to be present for this functionality to work.

0 Kudos
KellyHutchins
Esri Frequent Contributor

Tracy,

Its a bit of a hack but you could hide the layer in the layer list with custom css.  In the example below we hide the first item in the layer list widget. To test in your app just replace the value 1 in the css below with the number of your layer in the list. Note that I haven't tested this extensively so there could be some unexpected behavior but its worth exploring.

.esriList > li:nth-child(1) {
    display: none;
}

View solution in original post

HunterCarver
Occasional Contributor

Kelly,

I'm new to css, any guidance on implementing this?  Which css are we using this in, LayerSelector.css?

0 Kudos
KellyHutchins
Esri Frequent Contributor

Are you using the Web App Builder developer edition? If so I'm not familiar enough with that app. Perhaps ask this question in the Web App Builder community? 

0 Kudos
by Anonymous User
Not applicable

Hi Tracy,

If this is still an issue, what I have usually been doing on my side...

If you are using WebApp Builder, when using the Layer List widget you can:

Uncheck the box for the layer that you don't want to see in the layer list. The layer can be turned on within the web map, but the choice to turn it on or off within the web app will nto appear.

Let me know if this is unclear...

TracySchloss
Frequent Contributor

As stated in my original posting, I'm using the Basic Viewer template.  I went another route with my project and didn't end up using AGOL at all.  I have enough HTML/JavaScript experience I just went with that option. 

0 Kudos