Feature request #9288
add $map, $composer variables to expression builder
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | - | ||
Pull Request or Patch supplied: | No | Resolution: | |
Easy fix?: | No | Copied to github as #: | 17899 |
Description
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.
Associated revisions
Implement $map variable, which returns the current composer map item id where the map is being drawn, or 'canvas' if the map is being drawn in the main QGIS window. Partly implements #9288.
History
#1 Updated by Nathan Woodrow almost 11 years ago
What use is the $map variable?
#2 Updated by Mathieu Pellerin - nIRV almost 11 years ago
$map returns the composer's map item name (i.e. 'map 0','map 1') when drawing onto a composer map item, or 'canvas' when drawing onto the qgis main window.
#3 Updated by Nathan Woodrow almost 11 years ago
Sure I understand what it returns what I don't see is the use case. Can you explain it a bit more. Maybe with a example.
#4 Updated by Nyall Dawson almost 11 years ago
- Status changed from Open to Closed
Fixed in changeset c45bf504e761e568e1bc100eda0edc3e00213907.
#5 Updated by Nyall Dawson almost 11 years ago
Needs to be re-opened. This is only partly implemented.
#6 Updated by Nathan Woodrow almost 11 years ago
I still don't see the use case for this. The value will change. If you have 3 map windows what is the expected outcome?
#7 Updated by Mathieu Pellerin - nIRV almost 11 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 almost 11 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.