Open antoniolocandro opened 3 years ago
And how does that work when you have multiple layouts opened or layouts with multiple maps? The map extent of the layout is specific to the scope of the layout. Accessing the scope of a potential item is hazardous, the closest we have is the getter which resides in a dedicated layout, not the level above. You would need to getter.
each layout shall have a unique identifier by default an incremental map0...map n that can be manually overridden should solve it, of course a test for manual override to see the same id is not used would also be needed.
In any case I am not talking about showing the dashed magenta line in the map canvas that is another thing that would be useful and I mentioned, I am talking of being able to get the layout extent geometry to use for functions, if you want to avoid issues something like layout_extent("layout_id") this should provide the extent geometry. Technically it is possible right now but very convoluted
For the magenta dashed line you could enable decorations and have a checkbox to turn layout extents on/off, you may want to see something like this for example
I would be happy to access the layout extent by item id as mentioned in the Kartoza blog post I referenced
There is a processing algorithm that allows to get the extent but the idea to have it as a variable is that then more data-driven cartography can be achieved through the use of data-defined fields and geometry generators
I don't know if there is another way to do this but for a project I wanted to only label those features that are within the layout print area which you can see when the layout is open and the decoration is enabled (would be great to have an option to have it enable without the layout open also but that's a different request)
When I used @map_extent variable it returned the map canvas which is to be expected so I would think a new variable layout_extent would be more appropriate? I got the idea from here https://kartoza.com/en/blog/getting-map-intersection-with-vector-layers-dynamically-in-qgis/
Since it didn't work my workaround was a bit convoluted to go to the layout, add a text box and get the geometry as WKT and convert the label to static to be able to copy the contents, then I could defined the Show label option with Data defined as shown here. use case is not spending time on labels that will not be seen on the final print layout. If there is already a possible way of doing something like this in a simpler way then I will just bang my head on the desk
https://user-images.githubusercontent.com/4627073/124517893-6393c080-dda2-11eb-9743-184e38364d16.mp4