#include <mapcontrol.h>
Public Types | |
enum | MouseMode { Panning, Dragging, None } |
Declares what actions the mouse move has on the map. More... | |
Public Slots | |
void | resize (const QSize newSize) |
Resizes the map to the given size. | |
void | scroll (const QPoint scroll) |
scrolls the view by the given point | |
void | scrollDown (int pixel=10) |
scrolls the view down | |
void | scrollLeft (int pixel=10) |
scrolls the view to the left | |
void | scrollRight (int pixel=10) |
scrolls the view to the right | |
void | scrollUp (int pixel=10) |
scrolls the view up | |
void | setZoom (int zoomlevel) |
sets the given zoomlevel | |
void | updateRequest (QRect rect) |
updates the map for the given rect | |
void | updateRequestNew () |
updates the hole map by creating a new offscreen image | |
void | zoomIn () |
zooms in one step | |
void | zoomOut () |
zooms out one step | |
Signals | |
void | boxDragged (const QRectF) |
Emitted, after a Rectangular is dragged. | |
void | geometryClicked (Geometry *geometry, QPoint coord_px) |
This signal is emitted, when a Geometry is clicked. | |
void | mouseEventCoordinate (const QMouseEvent *evnt, const QPointF coordinate) |
Emitted AFTER a MouseEvent occured. | |
void | viewChanged (const QPointF &coordinate, int zoom) |
This signal is emitted, after the view have changed. | |
Public Member Functions | |
void | addLayer (Layer *layer) |
adds a layer | |
QPointF | currentCoordinate () const |
returns the coordinate of the center of the map | |
int | currentZoom () const |
returns the current zoom level | |
void | enablePersistentCache (const QDir &path=QDir::homePath()+"/QMapControl.cache") |
Enable persistent caching of map tiles. | |
void | followGeometry (const Geometry *geometry) const |
Keeps the center of the map on the Geometry, even when it moves. | |
Layer * | layer (const QString &layername) const |
returns the layer with the given name | |
QList< QString > | layers () const |
returns the names of all layers | |
MapControl (QSize size, MouseMode mousemode=Panning) | |
The constructor of MapControl. | |
MapControl::MouseMode | mouseMode () |
returns the current MouseMode | |
void | moveTo (QPointF coordinate) |
Smoothly moves the center of the view to the given Coordinate. | |
int | numberOfLayers () const |
returns the number of existing layers | |
void | setMouseMode (MouseMode mousemode) |
sets the Mouse Mode of the MapControl | |
void | setProxy (QString host, int port) |
Sets the proxy for HTTP connections. | |
void | setView (const Point *point) const |
sets the view to the given Point | |
void | setView (const QList< QPointF > coordinates) const |
sets the view, so all coordinates are visible | |
void | setView (const QPointF &coordinate) const |
sets the middle of the map to the given coordinate | |
void | setViewAndZoomIn (const QList< QPointF > coordinates) const |
sets the view and zooms in, so all coordinates are visible | |
void | showScale (bool show) |
Displays the scale within the widget. | |
void | stopFollowing (Geometry *geometry) |
Stops the following of a Geometry. |
This is the main widget. To this control layers can be added. A MapControl have to be instantiated with a QSize which sets the size the widget takes in a layout. The given size is also the size, which is asured to be filled with map images.
enum MouseMode |
MapControl | ( | QSize | size, | |
MouseMode | mousemode = Panning | |||
) |
The constructor of MapControl.
The MapControl is the widget which displays the maps. The size describes the area, which gets filled with map data When you give no MouseMode, the mouse is moving the map. You can change the MouseMode on runtime, to e.g. Dragging, which lets the user drag a rectangular box. After the dragging a signal with the size of the box is emitted. The mousemode ´None´ can be used, to completely define the control of the map yourself.
size | the size which the widget should fill with map data | |
mousemode | the way mouseevents are handled |
References MapControl::updateRequestNew().
void addLayer | ( | Layer * | layer | ) |
adds a layer
If multiple layers are added, they are painted in the added order.
layer | the layer which should be added |
void boxDragged | ( | const QRectF | _t1 | ) | [signal] |
Emitted, after a Rectangular is dragged.
It is possible to select a rectangular area in the map, if the MouseMode is set to Dragging. The coordinates are in world coordinates
QRectF | the dragged Rect |
QPointF currentCoordinate | ( | ) | const |
returns the coordinate of the center of the map
int currentZoom | ( | ) | const |
returns the current zoom level
void enablePersistentCache | ( | const QDir & | path = QDir::homePath() + "/QMapControl.cache" |
) |
Enable persistent caching of map tiles.
Call this method to allow the QMapControl widget to save map tiles persistent (also over application restarts). Tiles are stored in the subdirectory "QMapControl.cache" within the user's home directory. This can be changed by giving a path.
path | the path to the cache directory |
void followGeometry | ( | const Geometry * | geometry | ) | const |
Keeps the center of the map on the Geometry, even when it moves.
To stop the following the method stopFollowing() have to be called
geometry | the Geometry which should stay centered. |
void geometryClicked | ( | Geometry * | geometry, | |
QPoint | coord_px | |||
) | [signal] |
Layer * layer | ( | const QString & | layername | ) | const |
returns the layer with the given name
layername | name of the wanted layer |
QList< QString > layers | ( | ) | const |
returns the names of all layers
void mouseEventCoordinate | ( | const QMouseEvent * | evnt, | |
const QPointF | coordinate | |||
) | [signal] |
Emitted AFTER a MouseEvent occured.
This signals allows to receive click events within the MapWidget together with the world coordinate. It is emitted on MousePressEvents and MouseReleaseEvents. The kind of the event can be obtained by checking the events type.
evnt | the QMouseEvent that occured | |
coordinate | the corresponding world coordinate |
MapControl::MouseMode mouseMode | ( | ) |
returns the current MouseMode
For a explanation for the MouseModes see setMouseMode()
void moveTo | ( | QPointF | coordinate | ) |
Smoothly moves the center of the view to the given Coordinate.
coordinate | the Coordinate which the center of the view should moved to |
int numberOfLayers | ( | ) | const |
returns the number of existing layers
void resize | ( | const QSize | newSize | ) | [slot] |
Resizes the map to the given size.
newSize | The new size |
void setMouseMode | ( | MouseMode | mousemode | ) |
sets the Mouse Mode of the MapControl
There are three MouseModes declard by an enum. The MouesMode Dragging draws an rectangular in the map while the MouseButton is pressed. When the Button is released a boxDragged() signal is emitted.
The second MouseMode (the default) is Panning, which allows to drag the map around.
mousemode | the MouseMode |
void setProxy | ( | QString | host, | |
int | port | |||
) |
Sets the proxy for HTTP connections.
This method sets the proxy for HTTP connections. This is not provided by the current Qtopia version!
host | the proxy´s hostname or ip | |
port | the proxy´s port |
void setView | ( | const Point * | point | ) | const |
sets the view to the given Point
point | the geometric point the view should be set to |
References Point::coordinate().
void setView | ( | const QList< QPointF > | coordinates | ) | const |
sets the view, so all coordinates are visible
coordinates | the Coorinates which should be visible |
void setView | ( | const QPointF & | coordinate | ) | const |
sets the middle of the map to the given coordinate
coordinate | the coordinate which the view´s middle should be set to |
void setViewAndZoomIn | ( | const QList< QPointF > | coordinates | ) | const |
sets the view and zooms in, so all coordinates are visible
The code of setting the view to multiple coordinates is "brute force" and pretty slow. Have to be reworked.
coordinates | the Coorinates which should be visible |
void setZoom | ( | int | zoomlevel | ) | [slot] |
sets the given zoomlevel
zoomlevel | the zoomlevel |
void showScale | ( | bool | show | ) |
Displays the scale within the widget.
show | true if the scale should be displayed |
void stopFollowing | ( | Geometry * | geometry | ) |
Stops the following of a Geometry.
if the view is set to follow a Geometry this method stops the trace. See followGeometry().
geometry | the Geometry which should not followed anymore |
void updateRequest | ( | QRect | rect | ) | [slot] |
updates the map for the given rect
rect | the area which should be repainted |
void viewChanged | ( | const QPointF & | coordinate, | |
int | zoom | |||
) | [signal] |
This signal is emitted, after the view have changed.
coordinate | The current coordinate | |
zoom | The current zoom |