Select to view content in your preferred language

How to hide the layer name in legend

2442
1
09-20-2016 12:53 AM
yanli
by
Emerging Contributor

 how to hide the layer name in legend? like the "Rivers" in the example Map with legend , Or  can i change the text ?

0 Kudos
1 Reply
PanagiotisPapadopoulos
Esri Regular Contributor

See here the same example with different layer name Edit fiddle - JSFiddle 

When you are creating the layerInfo in order to pass it on the Legend widget change the layer title

....

map.on("layers-add-result", function (evt) {
var layerInfo = arrayUtils.map(evt.layers, function (layer, index) {
if (layer.layer.name==="Rivers"){
return {layer:layer.layer, title:"My River"};
}else{
return {layer:layer.layer, title:layer.layer.name};
}

}); 

...

Also it is more easily to use webmap for the map creation and control the layer name, legend visibility e.t.c from the webmap.