I have a method to create a feature layer. it consists of polygons. Each represent a unit. these units have a field of unit_type. Based on the type I would the polygon to have a different color.
I created a renderer to handle the logic
my_renderer = {
"type": "uniqueValue",
"field1": "unit_type",
"uniqueValueInfos": [
{
"value": "YES_WORK",
"symbol": {
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [0, 0, 255, 128], # Blue
"outline": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [255, 255, 255, 255],
"width": 1
}
},
"label": "Yes Work"
},
{
"value": "NO_WORK",
"symbol": {
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [255, 0, 0, 128], # Red
"outline": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [255, 255, 255, 255],
"width": 1
}
},
"label": "NO_WORK"
}
],
"defaultSymbol": {
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [0, 0, 255, 128], # Default color (Blue)
"outline": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [255, 255, 255, 255],
"width": 1
}
},
"defaultLabel": "Default"
}
and to pass it here to create the layer
operational_layers.append(
{
"url": f"{FEATURE_LAYER_URL}/0",
"type": "FeatureLayer",
"title": "ProjectBoundaries",
"token": SOME_TOKEN,
"opacity": 0.4,
"minScale": 0,
"maxScale": 0,
"renderer": my_renderer # Ensure the renderer is included here
}
)
export_map_task_payload = {
"operationalLayers": operational_layers,
"mapOptions": {
"extent": extent,
"spatialReference": {
"latestWkid": 3857,
"wkid": 102100
},
"showAttribution": True,
},
"exportOptions": {
"outputSize": [800, 800]
}
}
but it doesn't work. What is wrong. and if this is not not the way how to achieve the requirement