1

I was commissioned to create a simple print layout. The basic-layout is very simple, it just contains one map with OopenStreetMap-layer.

I want to add the Xmin, Xmax, Ymin and Ymax of this map (like all the values in the extention-tab) as text field. The text field should then display the coordinates of the map's corners, and should automatically adjust when I zoom in or out, so copy&paste is not an option.

3

To get the coordinates of the upper right corner of your map, use the following expression:

round(x_max(map_get(item_variables('Karte'),'map_extent')))||', '||round(y_max(map_get(item_variables('Karte'),'map_extent')))

item_variables('Karte') points at the item you want to work with. You need to replace Karte with the name you gave your map item.

map_get([...],'map_extent') grabs the extent of the item you're pointing at. In this case you're returned a geometry.

Once you get the geometry, the rest is rather easy:

Use y_min, y_max, x_min and x_max followed by the geometry you need the coordinates of to grab said coordinates. Combine min/max and x/y in order to create the fitting coordinate pairs. ||', '|| concatenates these coordinates.

I added the round function since I tried this using a UTM-zone and didn't want unnecessarily long numbers. If you're working with DMS-coordinates, please remove round since it'd probably break the expression.

| improve this answer | |

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.