Select to view content in your preferred language

How do I add multiple layers to the Legend widget?

9709
10
Jump to solution
05-10-2016 06:38 AM
EmilyRenkema1
Deactivated User

The Legend Widget sample and API page demonstrate how to add one layer to the widget, but I want to add multiple layers. I know that if I don't include the layerInfos property, all the layers will show, but what syntax do I need to use in order to add just the layers I want and to have more control over what it says next to each layer? I tried this:

var legend = new Legend({

      view: view,

      layerInfos: [{

          layer: [parkingLayer, votingLayer],

          title: "Random Layers"

     }]

});

legend.startup();

view.ui.add(legend, "bottom-right");

What I get is a little box at the bottom right that says "No Legend".

Another odd thing is that when I add only one layer it works except my title doesn't show up. If I only add the parking layer it says "Main Map-Parking Lots" next to it, but no title.

Any pointers on this are much appreciated.

0 Kudos
10 Replies
EmilyRenkema1
Deactivated User

Thanks for the help from everyone, I really appreciate it!

0 Kudos