Select to view content in your preferred language

add layer values to legend

878
5
07-26-2017 02:35 AM
FaryalSafdar
Emerging Contributor

i have created a legend.

var legend = new Legend({      map: map,      layerInfos: [        {          layer: S_layer,          title: "Factors"        }       ]    }, "legendDiv");     legend.startup();  

now i want to add another attribute of the same layer into the legend. i have seen examples of adding another layer to the legend . but could not find any example of how to add attributes of same layer to the legend. can anyone tell me how to solve this problem?

0 Kudos
5 Replies
EvelynHernandez
Frequent Contributor

I still dont understand what u wanna do, but this example may help u.

In the service they setted up a feature layer with 5 different symbol types and they made just one legend that containts the layers that have been added in the map.

ArcGIS API for JavaScript Sandbox 

0 Kudos
FaryalSafdar
Emerging Contributor

thanks for your response. but this example has two different layer. my problem is, i have to display different attributes of

same layer in the legend. for example in the pictureit shows only one factor i want to add another factor like temp of the same layer in this legend

0 Kudos
EvelynHernandez
Frequent Contributor

Im not sure if u can do that programatically, so why u dont use arcmap for having a layer with multiple factors?.

Most of the time u need to use more than 1 layer to represent different kind of things, for example temperature and wind Also , maybe u will need to have a dynamic layer for showing more than 1 factor at the time in the legend, in that way u can have 2 or more layers in the same service.

0 Kudos
FaryalSafdar
Emerging Contributor

but if we have 2 or more layer in the same service like r_soil layer, r_temp layer etc. is it appropirate way to do it? because i have to create a gdb of soil map and temp layer of many cities. and it shows on the map by user demand

0 Kudos
FaryalSafdar
Emerging Contributor

sir if we add another forexample temperature. then can we extract particular temp i.e of one city. and display in the legend?

0 Kudos