How do I resize symbols from a 2525 dictionary renderer?

905
6
Jump to solution
10-22-2021 07:28 AM
TroyFoster
Occasional Contributor

I finally got my runtime qt app converted over from 100.4 to 100.11.  I remember from one of the devsummit briefs that 2525 dictionary symbols were able to be resized in a later release. Is there a sample or code snippet displaying how to resize those dictionary symbols?

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

There is no sample at the moment. Here is the doc - https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-dictionaryrenderer.html#setSca...

 

Here is an example we have in our tests:

 

// Simple case... double the size 
ArcadeExpression* arcadeExpression = new ArcadeExpression("2", this);
dictionaryRenderer->setScaleExpression(arcadeExpression);

// More advanced case... double the size if the identity_code attribute is 4
ArcadeExpression* arcadeExpression = new ArcadeExpression("iif($feature.Identity_code == 4, 2,1)", this);
dictionaryRenderer->setScaleExpression(arcadeExpression);

 

Here is an Arcade reference you can use to write your expressions - https://developers.arcgis.com/arcade/ 

View solution in original post

0 Kudos
6 Replies
LucasDanzinger
Esri Frequent Contributor

There is no sample at the moment. Here is the doc - https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-dictionaryrenderer.html#setSca...

 

Here is an example we have in our tests:

 

// Simple case... double the size 
ArcadeExpression* arcadeExpression = new ArcadeExpression("2", this);
dictionaryRenderer->setScaleExpression(arcadeExpression);

// More advanced case... double the size if the identity_code attribute is 4
ArcadeExpression* arcadeExpression = new ArcadeExpression("iif($feature.Identity_code == 4, 2,1)", this);
dictionaryRenderer->setScaleExpression(arcadeExpression);

 

Here is an Arcade reference you can use to write your expressions - https://developers.arcgis.com/arcade/ 

0 Kudos
TroyFoster
Occasional Contributor

That just cleaned up about 130 lines of janky workaround to resize the symbols

KerryRobinson
Esri Contributor

Hi Troy.  Yes, as Lucas mentioned, there is a new `scaleExpression` method on the Dictionary Renderer that can accept either a constant or an Arcade expression.   So it doesn't set your symbol to a specific size, but you can scale all symbols based on a specific value, or use the expression to scale based on an attribute, map scale, etc. 

0 Kudos
VittorioBarulli
New Contributor

I'm using ArcGis 100.15(Qt) but I'm not able to use 'scaleExpression", 

to be clearer:

  • I'm able to put on the map graphical elements from dictionarySymbolStyle(created with mil2525d.stylx),
  • Symbols generated from dictionarySymbolStyle are rendered inside a GraphicsOverlay by using a Graphic object
  • the GraphicsOverlay object is rendered (setRenderer) with DictionaryRenderer create with dictionarySymbolStyle (at point 1)

But if I try to use:

ArcadeExpression* arcadeExpression = new ArcadeExpression("2", this);
renderer->setScaleExpression(arcadeExpression);

nothing happens on the screen, the symbol is always drawn with default dimension.

 I tryed to setScaleExpression during initialization and during runtime, but also the same result!

Do you have some advice?

0 Kudos
VittorioBarulli
New Contributor

It' funny, 

I found the solution just after my question.
The issue was that I used fetchSymbol to create the symbol inside the Graphics.
Instead, the correct way is to fill attribute() of the Graphics with proper properties.

 

0 Kudos
KerryRobinson
Esri Contributor

Hi- If you don't need to set the scale based on an attribute value, you can also just use a constant value for setScaleExpression, like this:

renderer->setScaleExpression(2);

 Otherwise, yes, you can set the attribute of the graphic and use that in an arcade expression to set the scale. 

Kerry

0 Kudos