3

I have an arrow marker (svg) that I use for photo location and direction on maps.

Under the arrow I want a label that is the number of the photo (photos by number are located elsewhere in a report). The number will have a white circle background. I can achieve this using Offset from Point and defining the quadrant and y value. Works for the arrow always pointing north. :)

The problem is that I cannot identify how to make the label rotate with the arrow marker/symbol such that it is always "under" the arrow (yet still oriented correctly as text).

enter image description here

As you can see, the arrow for image 2 points east but the label has not changed its position to still be inside the chevron.

"Use data defined properties for rotation with the same field on both marker and label"

Any online guide that explains this process?

I don't even understand the terms you are using.

Subsequent to the answer with examples:

After inputing the parameters you suggested (cutting and pasting your coding) it gave the message "Result of the expression is not a geometry."

enter image description here

And the result was that the circle and number disappear altogether.

enter image description here

project (make_point ($x,$y), 1, radians(45)) version below

enter image description here

2
  • 1
    Please provide an example image.
    – Erik
    Mar 31, 2022 at 13:16
  • Use data defined properties for rotation with the same field on both marker and label
    – J.R
    Mar 31, 2022 at 14:41

1 Answer 1

5

Use Geometry Generator for label placement with Offset from point and use this expression (see below for variants A)if the solution should fit different map scales and B) if the labels itself should also be rotated):

project (
    make_point ($x,$y),
    2500,  -- change the distance to fit your needs
    -radians(180 - "rotation") -- rotation is the name of the attribute containing rotation values
)

The red dot indicates the actual point geometry; the value of 2500 in the above expression is the distance from this point: enter image description here

If you zoom in and out, a fixed distance is not ideal as the label moves too far away from or comes too close to the arrow. To fit different scales, use a small distance value and multiply it with the variable @map_scale:

project (
    make_point ($x,$y),
    0.016 *  @map_scale,
    -radians(180-rotation)
)

enter image description here

enter image description here

If you want to rotate the labels as well, go down to Data defined and set a data driven override for Rotation, where you just set the attribute that contains the rotation angle (the same you used for the arrows).

enter image description here

10
  • Wow. Comprehensive response. Many thanks! Mar 31, 2022 at 21:27
  • Although, went I went to use it it didn't work. Not sure why. Mar 31, 2022 at 21:58
  • Good to know the site etiquette. I will check. Mar 31, 2022 at 21:58
  • Do you have an attribute named rotation? If not, replace this part in the expression with the ratation value you have. If it still doesn't work: can you provide sample data?
    – Babel
    Mar 31, 2022 at 22:25
  • Please test: does make_point ($x,$y) produce a geometry? If so, try project (make_point ($x,$y), 1, radians(45)) - what happens then?
    – Babel
    Mar 31, 2022 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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