Good Day
I have a layer that which uses a valueExpression in the Unique Value Renderer to set it's style, giving me something like:
I'm running into a problem where I need to know what colours / uniqueValueInfo from the Unique Value Renderer was set on to the map. How can I get this information? I tried running a query:
queryAllFeatures(layer: FeatureLayer): Promise<Graphic[] | Error> {
return new Promise((r, j) => {
const query = {
where: '1=1',
outFields: ['*'],
returnGeometry: true
}
layer.queryFeatures(query).then((queryRes) => {
r(queryRes.features);
}).catch((error) => {
console.log(error);
j(null);
})
});
}
But I can't seem to find the information in the output? I would imagine it's trivial to get the style information form the layer. Ideally I'd like to get a list of all styles / colours that are active.
Is this possible?
Thanks
If I'm understanding your question properly, it seems to me that UniqueValueRenderer.getUniqueValueInfo is the key to what you're trying to do. For example:
layer.renderer.getUniqueValueInfo(someGraphic).then(function(uniqueValueInfo) {
var symbol = uniqueValueInfo.symbol;
//do whatever with the symbology for "someGraphic" here
});