5

I would like to decrease the opacity of my layer when zooming out.

I prepared something like this:

 Case
 When @map_scale>1750 Then (1 - transparency) * 255
 End

It doesn't work.

The similar thread is here:

How to set transparency per polygon in a shapefile in QGIS?

but applies to the shapes

How to make the scale-dependant label transparency?

6
  • Are we talking about total label transparency, or only the background?
    – Erik
    Oct 14 '20 at 8:29
  • Where do you use this condition?
    – Taras
    Oct 14 '20 at 8:34
  • 1
    Also, what is "transparency"? An attribute column? If so, what are its contents? Furthermore, why are you multiplying by 255?
    – Erik
    Oct 14 '20 at 8:36
  • I mean label opacity
    – MKR
    Oct 14 '20 at 8:43
  • 1
    First tab of Edit (lable) rule has an Opacity slider
    – BERA
    Oct 14 '20 at 8:52
4

The expression for label opacity based on scale:

if(@map_scale>1750, 50, 100)

The expression for polygon fill opacity based on scale:

color_rgba(255, 0, 0, ( 1 - if(@map_scale>1750, 0.5, 0)) * 255)

Now both the labels and polygon fills are 50% transparent if you zoom out of the 1:1750 scale. The different syntax is caused by the fact that label opacity is a value in range [0, 100], while polygon fill is constructed as an RGB alpha color.

4

Apply the following query for the opacity of labels in the Expression String Builder (Expected Format: int[0-100])

CASE
WHEN @map_scale> 750 THEN 20
END

Map Scale: 1:578

enter image description here

Map Scale: 1:1157

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.