Bug report #18729

[Layout] Locking map item xmin/ymin with data-defined button is not taken into consideration when the scale is changed in the spinbox

Added by Harrissou Santanna about 2 years ago.

Category:Map Composer/Printing
Affected QGIS version:3.1(master) Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:26616


Use case: I have a map item i exported and used in a graphic editor software; but the extent used is not enough so I need to prepare another wider layout, at the same scale.
As resizing a map item does not resize the map canvas and keep its current scale (see #12698) I opted to fix the xmin/ymin coordinates to have a reference point I can use while importing.

Select and duplicate the map item (for reference)
Copy-paste its current xmin and ymin value into their associated data-defined expression. Now:

  1. use the "select item" tool to resize the map item: the xmin/ymin point is kept while the scale is resized. Good so far. we'd just then need to adjust the scale.
  2. change the value in the scale box of the map item: map item extent is zoomed (in or out) around its center point and the constrained xmin/ymin point is moved (the constraint is lost).
  3. Refreshing the dialog replaces the point at the xmin/ymin and rescales again the map item but, still the scale is not the entered one.

The only way I found to get the result is to use the "move item content" tool and panning the map canvas: instead of panning the map extent, it rescales it following a homothetic transformation where the xmin/ymin fixed point is the center ie, scale changes but the xmin/ymin point is kept. With trial and error, i update the scale until I reach the expected result.

I don't know how I could summarize the best behavior in this case but I feel that the result should be not an iterative process. Maybe applying these rules:

  1. if no coordinate is data-defined: zoom from the map item center point (I guess it's the way it's currently done)
  2. if one point/coordinate is data-defined, place this point and zoom from it (homothetically), applying the provided scale
  3. If all the coordinates are data-defined (two points locked or coordinates of the two points data-defined), then resize the map item to match the provided scale

Also available in: Atom PDF