Developing a Table of Contents to turn on\off layers... anyone try this?

11925
47
Jump to solution
04-10-2015 09:01 AM
MikeCrook
New Contributor III

I'm developing a Table of Content to turn on\off layers on map using javascript \ dojo-AMD sdk. I found a few places on the internet that shows ways. Nothing that is making complete sense to a newbie. Has anyone done this in a way that makes sense?

Tags (1)
47 Replies
BenFousek
Occasional Contributor III

Kind of. If you turn off a layer group with say 3 of 6 layers visible and then turn it back on all layers of the group are visible.

0 Kudos
SimonFisher
Occasional Contributor II

Matt,

Can you provide anymore info in this possibly being added to the ArcGIS JavaScript API?  When?  What functionality might it have? 

Thanks

Simon

0 Kudos
SimonFisher
Occasional Contributor II

I see with the latest JS API release 3.14 there is now a LayerList widget in the API in Beta.

LayerList | API Reference | ArcGIS API for JavaScript

by Anonymous User
Not applicable

facebooklike2_icon.png

0 Kudos
by Anonymous User
Not applicable

@ ESRI developers:

There is a bug:  It does not uncheck sublayers if you uncheck the group.

(as detailed here WebApp Builder TOC bug  and About upcoming JSAPI 4.0 beta 1  )

You should also at least have an option to make it collapse the list of layers. (roll them up).  And gray out scale dependent layers beyond scale.

In other words, make it like @Nianwei's AGS JS TOC.

0 Kudos
KenBuja
MVP Esteemed Contributor

It would be useful to be able to exclude layers from a service, also.

by Anonymous User
Not applicable

Ken, I second this.  By the way, thank you for your past TOC examples, they were very helpful.

0 Kudos
SimonFisher
Occasional Contributor II

If we are going for a wish list here, it would also be nice to have at a bare minimum these features in the new LayerList;

-ability to alter transparency of each service

-included legend

-ability to move services up/down

MattDriscoll
Esri Contributor

I think we'd like to keep it simple and make sure it's intent is not for editing a map but for performing simple layer adjustments as a viewer.

Keeping a legend out would be best as we have a legend dijit for that and combining the two makes a complicated, unfriendly user interface.

Good suggestions so far:

- Layer transparency slider.

- Excluding specific sublayers.

- Greying out scale dependent sublayers. (parent layers already do this)

- Collapsable option or sublayers collapsed when not visible.

Keep em' coming

KenBuja
MVP Esteemed Contributor

While altering layer transparency isn't built in to the class, it does give you the option of adding your own slider with the "content" object in the layers property. You'll have to code its functionality

var myWidget = new LayerList({
    map: map,
    layers: [{
        layer: atlasLayer,
        id: "Atlas layers",
        content: "horizontalSlider",
        subLayers: true
    }],
}, "layerList");

<div id="horizontalSlider"
     style="width:80%;"
     name="horizontalSlider"
     data-dojo-type="dijit/form/HorizontalSlider"
     data-dojo-props="value:6,
            minimum: -10,
            maximum:10,
            discreteValues:11,
            intermediateChanges:true,
            showButtons:false">
</div>

slider.png