Skip to main content
deleted 4 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Thank you for those first answers. As I have poor knowledge of coding, it'll take time before I meet a result.

My research led me to a plugin (Layout loader)  , which is able when opening the composer to zoom directly to the canevascanvas location. However, for certain reasons, I am not likely to use that plugin, and so I'll carry on with your solutions.

Here is the link to the plugin : link to Github

And here, an extract of the code:

        # Get current canvas extent and apply that to all maps (items) in layout
    # Replace any text "{{title}}" in any layout label with the dialog Title text
    canvas = iface.mapCanvas()
    for item in l.items():
        if item.type()==65639: # Map
            item.zoomToExtent(canvas.extent())
        if item.type()==65641: # Label
            item.setText(item.text().replace('{{title}}',title_text))
# Get current canvas extend and apply that to all maps (items) in layout
# Replace any text "{{title}}" in any layout label with the dialog Title text
canvas = iface.mapCanvas()
for item in l.items():
    if item.type()==65639: # Map
        item.zoomToExtent(canvas.extent())
    if item.type()==65641: # Label
        item.setText(item.text().replace('{{title}}', title_text))

Thank you for those first answers. As I have poor knowledge of coding, it'll take time before I meet a result.

My research led me to a plugin (Layout loader)  , which is able when opening the composer to zoom directly to the canevas location. However for certain reasons, I am not likely to use that plugin, and so I'll carry on with your solutions.

Here is the link to the plugin : link to Github

And here, an extract of the code:

        # Get current canvas extent and apply that to all maps (items) in layout
    # Replace any text "{{title}}" in any layout label with the dialog Title text
    canvas = iface.mapCanvas()
    for item in l.items():
        if item.type()==65639: # Map
            item.zoomToExtent(canvas.extent())
        if item.type()==65641: # Label
            item.setText(item.text().replace('{{title}}',title_text))

Thank you for those first answers. As I have poor knowledge of coding, it'll take time before I meet a result.

My research led me to a plugin (Layout loader), which is able when opening the composer to zoom directly to the canvas location. However, for certain reasons, I am not likely to use that plugin, and so I'll carry on with your solutions.

Here is the link to the plugin : link to Github

And here, an extract of the code:

# Get current canvas extend and apply that to all maps (items) in layout
# Replace any text "{{title}}" in any layout label with the dialog Title text
canvas = iface.mapCanvas()
for item in l.items():
    if item.type()==65639: # Map
        item.zoomToExtent(canvas.extent())
    if item.type()==65641: # Label
        item.setText(item.text().replace('{{title}}', title_text))
Source Link
Remi.M
  • 119
  • 6

Thank you for those first answers. As I have poor knowledge of coding, it'll take time before I meet a result.

My research led me to a plugin (Layout loader) , which is able when opening the composer to zoom directly to the canevas location. However for certain reasons, I am not likely to use that plugin, and so I'll carry on with your solutions.

Here is the link to the plugin : link to Github

And here, an extract of the code:

        # Get current canvas extent and apply that to all maps (items) in layout
    # Replace any text "{{title}}" in any layout label with the dialog Title text
    canvas = iface.mapCanvas()
    for item in l.items():
        if item.type()==65639: # Map
            item.zoomToExtent(canvas.extent())
        if item.type()==65641: # Label
            item.setText(item.text().replace('{{title}}',title_text))