Feature request #9288
add $map, $composer variables to expression builder
|Pull Request or Patch supplied:||No||Resolution:|
|Easy fix?:||No||Copied to github as #:||17899|
Looking at the atlas expression variable, I realized a $map and $composer variables would be really useful.
The $map variable would return:
- 'canvas' when main qgis canvas is being drawn
- 'map 0', 'map 1', etc. when the corresponding qgis composer map items are redrawn.
The $composer variable would return composer name if drawn within a composer, or null if drawn by main qgis canvas.
It would greatly expend what can be done via multiple map items in composer sheets. Right now, it's pretty much limited to the [x] lock layers option.
#7 Updated by Mathieu Pellerin - nIRV over 6 years ago
(Summing up the discussion over IRC)
Case scenario #1:
- User wants to output a large A2 poster with 4 map items showing a number of sub-provincial divisions and want to highlight via polygon fill color the focus sub-division in each of the map item. The user input the sub-provincial division ID (let's say defined by a "division_id" column) to each map item ID and use the following data-defined expression for the color fill: "if $map = $division_id '(150,150,0)' else '(255,255,255)'" or use the rule-based symbology with the following filter "$map = $division_id"
Case scenario #2:
- User wants to output one page with two map items showing different POIs from one point layer (say an OSM point layer export). The user sets each map item ID to use a string (i.e. 'bars', 'hotels') that will be used in an expression to match a column's content in the point layer, says "$map = $feature_amnenity"
#8 Updated by Mathieu Pellerin - nIRV over 6 years ago
- File map-var-showcase.png added
Attaching a screenshot that showcases a very basic use of the $map variable to highlight a specific polygon via a color fill data-defined expression matching a polygon's ID to the $map item name. It also uses a data-defined expression to show the label for the highlighted polygon.