Graphics Reference
In-Depth Information
• A list of the currently shown
map layers
. This can be accessed using the
lay-
ers()
method.
Tip
Note that there is a subtle difference between the list of map layers available with-
in the map canvas and the list of map layers included in the
QgisInter-
face.legendInterface()
method. The map canvas's list of layers only in-
cludes the list of layers currently visible, while
QgisInter-
face.legendInterface()
returns all the map layers, including those that
are currently hidden.
• The
map units
used by this map (meters, feet, degrees, and so on). The map's
map units can be retrieved by calling the
mapUnits()
method.
• An
extent
,
which
is the area of the map currently shown within the canvas. The
map's extent will change as the user zooms in and out, and pans across the map.
The current map extent can be obtained by calling the
extent()
method.
•
A current map tool
that is used to control the user's interaction with the contents
of the map canvas. The current map tool can be set using the
setMapTool()
method, and you can retrieve the current map tool (if any) by calling the
mapTool()
method.
• A
background color
used to draw the background behind all the map layers. You
can change the map's background color by calling the
canvasColor()
meth-
od.
• A
coordinate transform
that converts from map coordinates (that is, coordinates
in the data source's coordinate reference system) to pixels within the window. You
can retrieve the current coordinate transform by calling the
getCoordin-
ateTransform()
method.
The QgsMapCanvasItem class
A
map canvas item
is an item drawn on top of the map canvas. The map canvas item will
appear in front of the map layers. While you can create your own subclass of
Qg-
sMapCanvasItem
if you want to draw custom items on top of the map canvas, you will
find it easier to use an existing subclass that does much of the work for you. There are
currently three subclasses of
QgsMapCanvasItem
that you might find useful:
•
QgsVertexMarker
: This draws an icon (an "X", a "+", or a small box)
centered around a given point on the map.