How to change a layer name in the legend ?

2249
2
Jump to solution
08-29-2016 05:58 AM
MathieuVILLEMONT1
Occasional Contributor

The API Reference state that one can modify the layer name displayed in the legend by specifying a title in layerInfos.

However when I do so in ArcGIS API for JavaScript Sandbox I don't see any change :

var legend = new Legend({
  view: view,
  layerInfos: [{
    layer: featureLayer,
    title: "My new title"
  }]
});
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

Change the Feature Layer name after loading and before initializing the legend:

featureLayer.title = "My Title";

View solution in original post

2 Replies
FC_Basson
MVP Regular Contributor

Change the Feature Layer name after loading and before initializing the legend:

featureLayer.title = "My Title";

View solution in original post

MathieuVILLEMONT1
Occasional Contributor

Indeed featureLayer.then(featureLayer.title = "My Title"); works like a charm.

Thanks !