MapControl Class Reference

The control element of the widget and also the widget itself. More...

#include <mapcontrol.h>

Inheritance diagram for MapControl:

List of all members.

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.
Layerlayer (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.


Detailed Description

The control element of the widget and also the widget itself.

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.

Author:
Kai Winter <kaiwinter@gmx.de>

Member Enumeration Documentation

enum MouseMode

Declares what actions the mouse move has on the map.

Enumerator:
Panning  The map is moved
Dragging  A rectangular can be drawn
None  Mouse move events have no efect to the map


Constructor & Destructor Documentation

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.

Parameters:
size the size which the widget should fill with map data
mousemode the way mouseevents are handled

References MapControl::updateRequestNew().


Member Function Documentation

void addLayer ( Layer layer  ) 

adds a layer

If multiple layers are added, they are painted in the added order.

Parameters:
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

Parameters:
QRectF the dragged Rect

QPointF currentCoordinate (  )  const

returns the coordinate of the center of the map

Returns:
returns the coordinate of the middle of the screen

int currentZoom (  )  const

returns the current zoom level

Returns:
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.

Parameters:
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

Parameters:
geometry the Geometry which should stay centered.

void geometryClicked ( Geometry geometry,
QPoint  coord_px 
) [signal]

This signal is emitted, when a Geometry is clicked.

Parameters:
geometry The clicked Geometry object
coord_px The coordinate in pixel coordinates

Layer * layer ( const QString &  layername  )  const

returns the layer with the given name

Parameters:
layername name of the wanted layer
Returns:
the layer with the given name

QList< QString > layers (  )  const

returns the names of all layers

Returns:
returns a QList with 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.

Parameters:
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()

Returns:
the current MouseMode

void moveTo ( QPointF  coordinate  ) 

Smoothly moves the center of the view to the given Coordinate.

Parameters:
coordinate the Coordinate which the center of the view should moved to

int numberOfLayers (  )  const

returns the number of existing layers

Returns:
returns the number of existing layers

void resize ( const QSize  newSize  )  [slot]

Resizes the map to the given size.

Parameters:
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.

Parameters:
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!

Parameters:
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

Parameters:
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

Parameters:
coordinates the Coorinates which should be visible

void setView ( const QPointF &  coordinate  )  const

sets the middle of the map to the given coordinate

Parameters:
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.

Parameters:
coordinates the Coorinates which should be visible

void setZoom ( int  zoomlevel  )  [slot]

sets the given zoomlevel

Parameters:
zoomlevel the zoomlevel

void showScale ( bool  show  ) 

Displays the scale within the widget.

Parameters:
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().

Parameters:
geometry the Geometry which should not followed anymore

void updateRequest ( QRect  rect  )  [slot]

updates the map for the given rect

Parameters:
rect the area which should be repainted

void viewChanged ( const QPointF &  coordinate,
int  zoom 
) [signal]

This signal is emitted, after the view have changed.

Parameters:
coordinate The current coordinate
zoom The current zoom


The documentation for this class was generated from the following files:

Generated on Wed Jul 29 12:38:10 2009 for QMapControl by  doxygen 1.5.9