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"))
  • Have you considered using the easy_label plugin? – Ian Turton Feb 22 '18 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. – Troy Buerge Feb 23 '18 at 14:20
  • but you could use it's label points to draw your own line – Ian Turton Feb 23 '18 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. – Troy Buerge Feb 23 '18 at 15:46
  • I tried that, but when I used the geometry generator I couldn't even get the lines to draw. – Troy Buerge Feb 23 '18 at 16:04

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
  • 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. – Troy Buerge Mar 1 '18 at 15:36
  • If you want help getting the bounds of the label, I think that merits being a separate question. – csk Mar 5 '18 at 21:08

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.