Select to view content in your preferred language

Override LayerList layer name in 3.16

8006
13
Jump to solution
05-19-2016 11:24 AM
SteveCole
Honored Contributor

So, awhile back, I posted this thread about changing the label associated with a layer checkbox in the LayerList widget. The solution posted in that thread (setting id: "some layer name") does not seem to work using the 3.16 API version of the layerList widget.

code snippet:

        // Initialize and set up the LayerList
        layerWidget = new LayerList({
           map: app.map,
           showLegend: true,
           showOpacitySlider: true,
           showSubLayers: false,
           layers: [
                {layer:wsdotBridgeLayer,
                visibility:true,
                id:"WSDOT Bridges"
                },
                {layer: KingCoBridgeLayer,
                visibility:true,
                id:"King County Bridges"                
                },
                {layer:priorityRoadsLayer,
                visibility:true,
                id:"Priority Roads"
                }
           ]},"layerList");
        layerWidget.startup();

Result at load:

layerList_layerLabel_3_16_example.jpg

Has anybody encountered this and found a solution?

Steve

0 Kudos
13 Replies
RobertScheitlin__GISP
MVP Emeritus

Mehretab,

  Actually it does have a title property it is just not documented.

0 Kudos
DavidColey
MVP Regular Contributor

The LayerList also honors the title option in the layers array, I find that helpful for individual feature layers:

var layerList = new LayerList({
    map: mapMain,
    showLegend: true,   
    layers: [{
    layer: lyrSide,
                title: "Sidewalks",
    },
    {
    layer: lyrBike,
                title: "Bicycle Lanes",
    },
    {
    layer: lyrTrans,
                title:"Transit Lines"
  },
  {
    layer: lyrShlt,
                title:"Sheltered Stops"
  },
  {
    layer: lyrStops,
                title:"Transit Stops"
  }]
    //layerInfo
   
    }, "layerListDiv");
SteveCole
Honored Contributor

David Coley​ THANK YOU! That's the golden ticket. Why hasn't this made it into the documentation?....

0 Kudos
DavidColey
MVP Regular Contributor

sure glad to help, I haven't been able to contribute in awhile.  Sometimes its just the small things

0 Kudos