I created a polygon layer ('Blattschnitt') with two sections of a route of interest, with a certain expansion and rotation. The rotation has been calculated, if needed.


attributes of 'Blattschnitt'-Layer

In the Layout I set up two Map-Windows (f.e. Map1 & Map2) wich I would like to link to the sections from the layer 'Blattschnitt'. Is there a possibility? I assume the Atlas function does not apply with two Maps in one layout?


2 Answers 2


You can use an expression in the data defined override of the map rotation in each map to reference the "rotate" attribute in the Blattschnitt layer.

enter image description here

For example, for the rotation of 'Map 1':

Either get the feature using the Blatt nr attribute:

        attribute:='Blatt nr',
        value:='Blatt 1'

Or simply by the feature id:


Both of these expressions will return -51,262. Use the expression again for 'Map 2' but alter the Blatt nr attribute value, or feature_id accordingly.

A dynamic solution

Alternatively, in the following example on my layer called sections, I use the main_angle function on the polygons to get the rotation angle dynamically. The section number is referenced automatically by substringing the Map id (in my case, the 5th character of the id is the number following Map). In this case, the same expression can be used on each map, provided the map id number matches the section number - no need to change anything.

enter image description here

            get_feature('sections', 'section', 'section ' || substr(@map_id, 5, 5))
        when @angle >= 90 and @angle < 180
        then -@angle + 90
        when @angle >= 0 and @angle < 90
        then 90 - @angle

enter image description here

  • wow, that dynamic function looks swsome. i hope i can reproduce the steps... :) Thank you very much so far. Can you tell me also how to set the extent of the maps to the extent of the geometries? In fact i have created the geometries by using the tool 'Create Layer from extent'...
    – Marek
    Commented Jan 25, 2023 at 21:43

To have both the Rotation and the Extent adapt automatically, you need to do the following:

  • apply the geometry rotation to the Map item Rotation (via the rotation field or the main_angle). You might want to use main_angle as it will ensure better consistency when the angle changes from quadrant to quadrant

  • set the Map item Extents based on the polygon geometry, and there's a trick as the polygon geometry (Xmin/Xmax/Ymin/Ymax don't work)

In my example, the layer containing the reference polygons is called ref, and polygons have an id field.

Set the Map item Rotation to :

90-main_angle(geometry(get_feature('ref','id',1))) where 1 is the id of the polygon you refer to in this case

Set the Map item Extents to:

Xmin field formula:


Apply the same formula for Xmax, Ymin, Ymax, replacing the first x_min(...) by x_max(...) and so on.

Replace the id number according to the targeted polygon (or use the suggested dynamic index)

Xmin setup for Map2 / polygin id = 2: enter image description here

Example 1:

enter image description here

enter image description here

Example 2:

enter image description here

enter image description here

The key part for the Extents is to rotate the polygon $geometry before extracting the min/max extents. If you just take the extent of the geometry itself, you don't get a suitable result:

enter image description here

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.