Hello all!
I have a very simple question. Using the javascript API I have the simplest feature layer one could have:
var villages_to_domains = new FeatureLayer({
url:
outfields: ["*"],
});
Now, without manually declaring a renderer for this feature layer, the hosted layer naturally provides this, and I can see the default renderer attributes via the service URL found via my portal on ArcGIS Online. The details are found under the Drawing Info: section and look a bit as follows:
{"renderer":{"visualVariables":[{"type":"sizeInfo","target":"outline","expression":"view.scale","valueExpression":"$view.scale","stops":[{"size":1.5,"value":31882},{"size":0.75,"value":99632},{"size":0.375,"value":398528},{"size":0,"value":797056}]}],"type":"uniqueValue","field1":"datafuku_3","defaultSymbol":{"color":[170,170,170,255],"outline":{"color":[153,153,153,64],"width":0.75,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"},"defaultLabel":"Other","uniqueValueInfos":[{"value":"Fukui","label":"Fukui","symbol":{"color":[237,81,81,255],"outline":{"color":[153,153,153,64],"width":0.75,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}},{"value":"Bakuryou","label":"Bakuryou","symbol":{"color":[20,158,206,255]
I would very much like to be able to access these color attributes from inside of my code. Any ideas on how to do this?
I have tried accessing them in a similar manner as below and printing them to the console to debug, but it always returns undefined.
console.log(villages_to_domains.renderer.uniqueValueInfos[0].color);
It keeps saying that the feature layer has no property renderer. Any ideas on how to fix this?
Or, if anybody knows of any other way to access a featureLayer's default color scheme, I would greatly appreciate any guidance!
Thank you!!!