How do I filter LegendInfoListModel

354
1
03-15-2019 12:30 PM
MKa
by
Occasional Contributor III

I need to hide the legend from a couple of layers or edit it slightly, but I am unable to figure out how to view the Model data that is represented on this page (I want to iterate the model and get Name, SymbolURL, LayerName, etc)?

LegendInfoListModel QML Type | ArcGIS for Developers 

I see how to used the mode using the example here

arcgis-runtime-samples-qt/BuildLegend.qml at 37f29d3634a2ee71933836e6546c58d42fcfe081 · Esri/arcgis-... 

But how do I update the legendinfos Model and remove an entry?  I don't even know how to view it?  I have tried json.stringify and legendinfos.forEach(function(element, index, array), but those just seem to return the colors and other information.  I want the information on the legendinfoListMode page so I can remove some layers and elements of that legend.

0 Kudos
1 Reply
LucasDanzinger
Esri Frequent Contributor

If you are using C++, the best way to do it would probably be to create a QSortFilterProxyModel. Since you are using QML, I'd suggest 2 different approaches:

1. In your delegate, set the visibility of the delegate based on some condition. Like if you don't want your "Trees" layer to show in the legend, then set the following in your delegate

visible: layerName !== "Trees"

2. Create a new ListModel object, then, loop through the original list model and only add the ones you want to the new ListModel. Something along these lines should work, but it seems less ideal because you have to maintain 2 versions of the list model.

0 Kudos