LegendViewModel
require(["esri/widgets/Legend/LegendViewModel"], function(LegendVM) { /* code goes here */ });
esri/widgets/Legend/LegendViewModel
Provides the logic for the Legend widget, which displays a label and symbol for interpreting the Renderer of each layer in a map. This class may be used to create custom, interactive Legend widgets.
const legend = new Legend({
view: view,
viewModel: new LegendViewModel({
view: view
})
});
view.ui.add(legend, "bottom-left");
Constructors
- new LegendViewModel(properties)
- Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
Collection<ActiveLayerInfo> | Collection of ActiveLayerInfo objects used by the legend view to display data in the legend. more details | more details | LegendViewModel | |
Boolean | Indicates whether to show the Basemap layers in the Legend. more details | more details | LegendViewModel | |
String | The name of the class. more details | more details | Accessor | |
Object[] | Specifies a subset of the layers in the map to display in the legend. more details | more details | LegendViewModel | |
String | The view model's state. more details | more details | LegendViewModel | |
MapView|SceneView | The view from which the widget will operate. more details | more details | LegendViewModel |
Property Details
- activeLayerInfos Collection<ActiveLayerInfo>autocast
Collection of ActiveLayerInfo objects used by the legend view to display data in the legend. Use this property to hide or display the layer's symbols in the legend when an ActiveLayerInfo is removed from or added to this collection.
- basemapLegendVisible Boolean
Indicates whether to show the Basemap layers in the Legend.
- Default Value:filterBasemaps
Example:legend.viewModel.basemapLegendVisible = true;
The name of the class. The declared class name is formatted as
esri.folder.className
.
Specifies a subset of the layers in the map to display in the legend. If this property is not set, all operational layers in the map will display in the legend. This property can be used to control layer display order in the legend. Objects in this array are defined with the properties listed below.
- state Stringreadonly
The view model's state.
Possible Values:"ready"|"disabled"
- Default Value:disabled
The view from which the widget will operate.