Vary transparency by scale/on zoom

1453
9
10-07-2021 04:04 PM
Status: Open
wayfaringrob
Frequent Contributor

I've got some polygons that I would like to essentially fade to nothing as you zoom in. This could be implemented as a visible range of some continuous sort or added similarly to the vary transparency by attribute setting. I could imagine some people might want other symbol attributes to change on zoom, too, but this idea is mainly for transparency.

The only workaround I can think of at the moment would be adding the layer multiple times, setting a different transparency for each, and changing the visible range for each. Oy!

9 Comments
Todd_Metzler

Good idea.    A typical use case is administrative boundaries seen at small scale/large area and imagery at large scale/small area.

This functionality is particularly desirable when creating basemaps for use in Field Maps and other mobile Internet disconnected workflows.

The blend settings in Map Viewer don't currently allow the desired functionality.

jcarlson

Option 1: Use vector tiles. In a vector tile style, you can set certain attributes like size, color, transparency, etc., to scale between set values at different zooms. Doesn't work for needing data access, though, like popups.

jcarlson_0-1633697608452.png

S7cbuXiZrY.gif

Option 2: Use the "Set from Attribute Values" together with $view.scale in the symbology properties. The following settings use $view.scale as the custom expression. Unfortunately, this doesn't seem to be a real solution to your situation. No matter how the expression is modified (-$view.scale, 1/$view.scale), it behaves the same in the map, in that features become more visible as you zoom in.

VUSOSbGT8Y.gif

 

wayfaringrob

@jcarlson, thanks for the tips! It seems like the first idea might work for the current scenario, but I do want pop-ups, and in that case, I'd have to add both a tile and vector (100% transparent) version of the same layer and maintain both when changes are made.

jcarlson

@wayfaringrobThankfully as of 2.8, I think, you can publish a feature service with a "linked" vector tile service, where you can just go in and click "rebuild cache" to update all the vector tiles. Much easier than updating vector tiles used to be.

wayfaringrob

@jcarlson  I'll have to check it out!

lzk222
by

Building off of @rburke-bsrc, I think this is now doable as you can flip the high-low scale percentages in the Transparency by attribute pane. The way I was able to get this to work for vector layers (pop-ups included) was to select any numerical attribute, subtract it from itself, add the $view.scale  global variable and divide by some arbitrary number (100 in this case) to make the upper and lower bounds numbers more comprehensible.

Here is the expression that worked for me. Note that IIR happens to be a numerical value in my attribute table. Could be any num value. 

($feature.IIR - $feature.IIR) + $view.scale / 100

Screenshot 2022-08-21 104706.png

The trick is that $view.scale upper bound (0% transparency in my case) is determined by the current zoom level you're at in the map viewer. For this reason I recommend zooming into the level you'd like to start seeing transparency before creating the custom expression.

If you want the polygons to go to nothing as you zoom in, set the transparency to 100% for low values.

Screenshot 2022-08-21 104446.png

DDI_transparency_zoom_demo3.gif

Note, I recommend against adjusting the expression once it's created. I've noticed issues after making edits to the initial expression. Best to make adjustments within the transparency by attribute panel.

wayfaringrob

@lzk222  neat, thanks for sharing that workaround.

wayfaringrob

Found a related idea for Pro: Scale-Based Transparency - Esri Community

BRENNEJM

@jcarlson Thanks for the tips here. It's nice that there's kind of a work around for this, but still annoying seeing as how varying symbology by zoom level is so common in other map services like MapBox.