Re-size symbology by View Scale

1321
11
08-19-2021 07:51 AM
KamillePreto
Occasional Contributor II

I am trying to create a custom expression on a feature so that it will re-size the symbology as I zoom in and out. Like this example ESRI Blog - https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/how-and-why-to-adjust-size-by-scale-...

However, everything I try, I keep getting errors.

I've also read this blog as well, but the steps are too complex for what I need to accomplish, as I don't have a layer I need to symbolize by attribute. - https://community.esri.com/t5/arcgis-living-atlas-blog/automatically-resize-symbols-by-map-scale-in/...

This is where I left off, basing off of the blogs:

Scale.JPG

I just have a simple layer for Manhole locations.

Manholes.JPG

This layer is a part of a Web Application for our Asset Management database (bridges, dams, outfalls, signals, inlets, pavement, etc). So there will be a lot of layers involved. I made a custom symbol for the Manholes & Inlets, and you cannot see the detail when the symbols are a smaller size.

Can anyone help let me know how to fix my expression? I will need to do this will all of the layers involved.

The scales listed in the expression were from one of the blogs, I did not set them myself.

Thank you! 

0 Kudos
11 Replies
jcarlson
MVP Esteemed Contributor

You can refer to the When page, but basically you need a default value at the very end for when none of the conditions are met. Just add ", 5" before the final parenthesis.

- Josh Carlson
Kendall County GIS
0 Kudos
KamillePreto
Occasional Contributor II

Hi Josh,

Thank you again. My script already has a ", 5" before the final parenthesis, so I added another just to see if it would work, but I am now getting a "Parse Error: Line 8: Unexpected identifier".

Scale2.JPG

var vs = $view.scale

when(
vs >=37000000, 30,
vs >=18500000, 20,
vs >=9300000, 10,
vs >=4700000, 8
vs >=2000000, 5, 5)

0 Kudos
jcarlson
MVP Esteemed Contributor

Now you're missing a comma after the 8.

- Josh Carlson
Kendall County GIS
0 Kudos
KamillePreto
Occasional Contributor II

Thanks for catching that. Fixed and updated to the script below.

var vs = $view.scale

when(
vs >=5000, 8,
vs >=2300, 15,
vs >=1200, 20,
vs >=600, 25, 5)

 

However, now this is what I'm getting - Scale3.JPG

But I don't believe it worked correctly. The symbols get smaller when I zoom in, and I wanted them to get larger. I also don't know what the legend is counting (>40, 30, 20, 10, etc). I still think I'm doing something wrong. Am I typing in the view scale incorrectly? I'm just super confused.

0 Kudos
jcarlson
MVP Esteemed Contributor

So, those numbers you're defining with your expression are just arbitrary values, they're not directly setting the symbol size number. What you'll need to do is to open the symbology settings to adjust the min/max values, as well as the min/max symbol sizes to match the min/max values from your expression.

jcarlson_1-1629387837913.png

- Josh Carlson
Kendall County GIS
0 Kudos
KamillePreto
Occasional Contributor II

Where do you see this option in Symbology settings? I don't have that.

0 Kudos
jcarlson
MVP Esteemed Contributor

Click the "Options" button.

- Josh Carlson
Kendall County GIS
0 Kudos
KamillePreto
Occasional Contributor II

I'm sorry, maybe my last question wasn't clear. I don't have the "View Scale Based" symbology options where you can customize a min/max. I only have the normal symbology options - choosing a symbol, transparency and visible range.

0 Kudos
jcarlson
MVP Esteemed Contributor

On your own screenshot, you have circled the options button.

jcarlson_0-1629394230541.png

 

"View Scale Based" is simply what I titled my expression.

- Josh Carlson
Kendall County GIS
0 Kudos