Select to view content in your preferred language

Change symbol color by attribute for DictionaryRenderer/DictionaryStyle works in ArcGIS Pro, but not in Maps SDK

1350
10
Jump to solution
11-01-2023 06:51 AM
BjørnarSundsbø1
Occasional Contributor II

Using the latest version of the Map SDK for ..NET, I am attempting to use a DictionaryRenderer as described in this post: https://developers.arcgis.com/net/styles-and-data-visualization/display-symbols-with-a-dictionary-re....

I need to merge multiple symbols into one, with rotation and changed color based on feature/graphics attributes. I am using this on a GraphicsOverlay.

A basic example from ArcGIS pro

BjrnarSundsb1_0-1698852304365.png

Using the same Dictionary Style in ArcGIS Map SDK for .NET. They all use the default color of the symbol defined in ArcGIS Pro.

BjrnarSundsb1_1-1698852337530.png

 

Rotation and hide/show different symbols based on graphics attributes work, however, the color does not want to change based on attribute value, with the important part

 

 

 

//Draw the arrow
keys = keys + "arrowBasic;";
keys = keys + "po:layers_arrow|FillColor|" + _urgcolor +";";
keys = keys + "po:structure_arrow|Rotation|" + _rotangle + ";";

 

 

 

The arcade script is as follows

 

 

 

var keys;
var _urgcolor;
var _standstillcolor;

//calculate ROTATION ANGLE for right-pointing arrow
var _rotangle = (450-$feature.Bearing)%360;

//calculate COLOR for urgency
function urg_color_calc (rsn,utc) {
if(rsn == "Ute av drift"){
return "#03376F" //blue-black
}
if(rsn == "Ledig"){
return "#D330D1" //lilac
}
if(utc == "A"){
return "#E75E5B" //red
}
if(utc == "H"){
return "#FFD75E" //yellow  
}
if(utc == "V"){
return "#7DD455" //green
}
if(isEmpty(utc)){
return "#b3b3b3" //grey
}
return "#0000ff"; //super blue as fallback
}

_urgcolor = urg_color_calc($feature.ResourceStatusName, $feature.urgencytypecode);

//Draw the arrow
keys = keys + "arrowBasic;";
keys = keys + "po:layers_arrow|FillColor|" + _urgcolor +";";
keys = keys + "po:structure_arrow|Rotation|" + _rotangle + ";";

// Motion - show the dot if Resource is standing still
 _standstillcolor = "#808b96";
if($feature.isMoving <1){ 
	keys = keys + "pentagon3;";
}

// See if text should be displayed.
var showLabels = $config.text != 'OFF';
// Create the concatenated string of keys (separated with ";"). Add the label key if text is on.
if (showLabels) {
  keys = keys + "labelres";
  }

return keys;

 

 

 

 

 

In the style there is a symbol with the primitiveName 'layers_arrow' of which I would like to change the color. using FillColor or Color has no effect in ArcGIS Map SDK for .NET, but it does work in ArcGIS Pro.

 

Using the following code to get the JSON of the symbol

Symbol restaurantSymbol = style.GetSymbolAsync(attributes).Result;
var json = restaurantSymbol.ToJson();
 

 

 

 

 

{
	"symbolLayers": [
	  {
		"anchorPoint": {
		  "x": 0,
		  "y": 0
		},
		"billboardMode3D": "FaceNearPlane",
		"colorLocked": false,
		"depth3D": 0.0,
		"dominantSizeAxis3D": "Y",
		"enable": true,
		"frame": {
		  "xmax": 17,
		  "xmin": 0,
		  "ymax": 17,
		  "ymin": 0
		},
		"markerGraphics": [
		  {
			"geometry": {
			  "rings": [
				[
				  [
					17,
					10.01
				  ],
				  [
					13.75,
					0
				  ],
				  [
					3.25,
					0
				  ],
				  [
					0,
					10.01
				  ],
				  [
					8.49,
					16.19
				  ],
				  [
					17,
					10.01
				  ]
				]
			  ]
			},
			"symbol": {
			  "angleAlignment": "Map",
			  "symbolLayers": [
				{
				  "capStyle": "Round",
				  "color": [
					0,
					0,
					0,
					255
				  ],
				  "colorLocked": false,
				  "enable": true,
				  "joinStyle": "Round",
				  "lineStyle3D": "Strip",
				  "miterLimit": 10.0,
				  "type": "CIMSolidStroke",
				  "width": 1.0
				},
				{
				  "color": [
					230,
					0,
					0,
					255
				  ],
				  "colorLocked": false,
				  "enable": true,
				  "type": "CIMSolidFill"
				}
			  ],
			  "type": "CIMPolygonSymbol"
			},
			"type": "CIMMarkerGraphic"
		  }
		],
		"primitiveName": "structure_pentagon3",
		"respectFrame": true,
		"scaleSymbolsProportionally": true,
		"size": 10.0,
		"type": "CIMVectorMarker",
		"verticalOrientation3D": false
	  },
	  {
		"anchorPoint": {
		  "x": 0,
		  "y": 0
		},
		"billboardMode3D": "FaceNearPlane",
		"colorLocked": false,
		"depth3D": 0.0,
		"dominantSizeAxis3D": "Y",
		"enable": true,
		"frame": {
		  "xmax": 0,
		  "xmin": -14,
		  "ymax": 4.5,
		  "ymin": -4.47
		},
		"markerGraphics": [
		  {
			"geometry": {
			  "x": 0,
			  "y": 0
			},
			"symbol": {
			  "haloSize": 0,
			  "scaleX": 1,
			  "symbolLayers": [
				{
				  "anchorPoint": {
					"x": 0.5,
					"y": 0
				  },
				  "billboardMode3D": "FaceNearPlane",
				  "clippingPath": {
					"clippingType": "Intersect",
					"path": {
					  "rings": [
						[
						  [
							0.0,
							0.0
						  ],
						  [
							17.0,
							0.0
						  ],
						  [
							17.0,
							17.0
						  ],
						  [
							0.0,
							17.0
						  ],
						  [
							0.0,
							0.0
						  ]
						]
					  ]
					},
					"type": "CIMClippingPath"
				  },
				  "colorLocked": false,
				  "depth3D": 0.0,
				  "dominantSizeAxis3D": "Y",
				  "enable": true,
				  "frame": {
					"xmax": 17,
					"xmin": 0,
					"ymax": 17,
					"ymin": 0
				  },
				  "markerGraphics": [
					{
					  "geometry": {
						"rings": [
						  [
							[
							  17,
							  9.33
							],
							[
							  11.52,
							  14.77
							],
							[
							  11.52,
							  12.58
							],
							[
							  0,
							  12.58
							],
							[
							  0,
							  6.07
							],
							[
							  11.52,
							  6.07
							],
							[
							  11.52,
							  3.88
							],
							[
							  17,
							  9.33
							]
						  ]
						]
					  },
					  "symbol": {
						"angleAlignment": "Map",
						"symbolLayers": [
						  {
							"capStyle": "Round",
							"color": [
							  51,
							  51,
							  51,
							  255
							],
							"colorLocked": false,
							"enable": true,
							"joinStyle": "Round",
							"lineStyle3D": "Strip",
							"miterLimit": 10.0,
							"type": "CIMSolidStroke",
							"width": 0.0
						  },
						  {
							"color": [
							  230,
							  152,
							  0,
							  255
							],
							"colorLocked": false,
							"enable": true,
							"type": "CIMSolidFill"
						  }
						],
						"type": "CIMPolygonSymbol"
					  },
					  "type": "CIMMarkerGraphic"
					}
				  ],
				  "offsetY": -0.6666666666666666,
				  "respectFrame": true,
				  "scaleSymbolsProportionally": true,
				  "size": 14.0,
				  "type": "CIMVectorMarker",
				  "verticalOrientation3D": false
				}
			  ],
			  "type": "CIMPointSymbol"
			},
			"type": "CIMMarkerGraphic"
		  }
		],
		"primitiveName": "structure_arrow",
		"respectFrame": true,
		"rotation": 327.0,
		"scaleSymbolsProportionally": true,
		"size": 14.0,
		"type": "CIMVectorMarker",
		"verticalOrientation3D": false
	  }
	],
	"type": "CIMPointSymbol"
  }

 

 

 

 

In the JSON above, I can find primitive names "structure_arrow" which I change the rotation for, and "structure_pentagon3" which is displayed or hidden. Nowhere in the JSON of the symbol can I find anything with the primitiveName 'layers_arrow", which is the name set in ArcGIS Pro for the symbol.

 

The relevant section from DB Browser for SQLite. Interestingly, the name layer arrow is visible in the binary display of the arrowBasic content 

BjrnarSundsb1_1-1698851249871.png

 

 

 

0 Kudos
10 Replies
PreetiMaske
Esri Regular Contributor

Glad to hear it is working for you. I am going to log an issue internally but I can't commit if it will be fixed in near term release. I will my best to set a priority on it. Once I know more I will update you on this thread.