3

I'm working on a map that has a lot of points in a small area, so I'm adding lines from my labels to their points using a Geometry generator in the symbol designer. The problem I'm having is that the lines always come from the bottom left corner of the label.

How do I get them to come from the part of the label that is closest to the point?

I'm using the following Expression and really don't have a clue where to go from there.

    make_line( make_point( $x,$y), make_point( "X","Y"))
7
  • Have you considered using the easy_label plugin? Commented Feb 22, 2018 at 9:00
  • I have tried it, and had some problems with it. it seems like it always wants to add some extra kinks in the lines. and I cant seem to get rid of them. Commented Feb 23, 2018 at 14:20
  • but you could use it's label points to draw your own line Commented Feb 23, 2018 at 14:25
  • I'll have to look into that. I'm still learning how to do some of that stuff, so don't always think of everything. Commented Feb 23, 2018 at 15:46
  • I tried that, but when I used the geometry generator I couldn't even get the lines to draw. Commented Feb 23, 2018 at 16:04

1 Answer 1

1

Changing the label alignment will change which corner of the label is located at the defined point.

enter image description here

Set up data-defined label alignment

  1. Add two new text fields, Align_H and Align_V
  2. Fill Align_H with the desired horizontal alignment of each label: left or right. Fill Align_V with the desired vertical alignment: bottom or top.
  3. Use these fields to control alignment under label properties. enter image description here
2
  • I'm getting somewhere now. I can draw a line based on a condition in the geometry generator expression area. What i would like to do is be able to get the bounds of my label now. something like this: 'CASE WHEN "Y" < $y THEN make_line(make_point("X", "Y_max" ),$geometry) END' Where "Y_Max" is the the top of the label, or "X_max" is the the right side. Commented Mar 1, 2018 at 15:36
  • If you want help getting the bounds of the label, I think that merits being a separate question. Commented Mar 5, 2018 at 21:08

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.