4

I have a point layer with one point in QGIS. Instead of rendering its real coordinates, I use it to generate a geometry-generator-based point always in the middle of map canvas (geom_from_wkt('POINT('||x( @map_extent_center )||' '||y( @map_extent_center )||')'))

If I move the original point outside map-canvas the symbol in the middle of the map-canvas is not rendered any longer too.

Is there a possibility to force QGIS to render this geometry-generator-point when its original coordinates are outside map-canvas ?

A virtual layer (as described in Displaying generated lines out of map extent using QGIS?) does not help, because virtual layers do not work with variables like @map_extent_center)

1 Answer 1

5

If instead of using a sacrificial point for your layer, you use a polygon, and again use the geometry generator trick to create a central point, then you can make the polygon arbitrarily large (even the whole globe in your project CRS) and it will always render the map-centre point because the polygon will always overlap your view.

Here's a sacrificial polygon with two layers, the red map-centre spot and an outline layer for clarity.

enter image description here

I can zoom in and the red spot is still centre even when the polygon outline isn't visible:

enter image description here

Here's my geometry for that layer:

enter image description here

Note the layer is in EPSG 3857 to match the project CRS.

(Also, using @map_extent_center for your geometry generator is quicker than constructing a WKT string.)

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.