Qt Mobility Reference Documentation

QGeoMapWidget Class Reference

The QGeoMapWidget class is used to display a map and manager the interactions between the user and the map. More...

 #include <QGeoMapWidget>

Public Types

enum MapType { NoMap, StreetMap, SatelliteMapDay, SatelliteMapNight, TerrainMap }

Public Functions

QGeoMapWidget ( QGeoMappingManager * manager, QGraphicsItem * parent = 0 )
virtual ~QGeoMapWidget ()
void addMapObject ( QGeoMapObject * mapObject )
QGeoCoordinate center () const
QPointF coordinateToScreenPosition ( const QGeoCoordinate & coordinate ) const
QList<QGeoMapObject *> mapObjects ()
QList<QGeoMapObject *> mapObjectsAtScreenPosition ( const QPointF & screenPosition )
QList<QGeoMapObject *> mapObjectsInScreenRect ( const QRectF & screenRect )
MapType mapType () const
qreal maximumZoomLevel () const
qreal minimumZoomLevel () const
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * parent )
void pan ( int dx, int dy )
void removeMapObject ( QGeoMapObject * mapObject )
QGeoCoordinate screenPositionToCoordinate ( QPointF screenPosition ) const
void setCenter ( const QGeoCoordinate & center )
void setMapType ( MapType mapType )
void setZoomLevel ( qreal zoomLevel )
QPainterPath shape () const
void startPanning ()
void stopPanning ()
QList<MapType> supportedMapTypes () const
QList<QGeoMapObject *> visibleMapObjects ()
qreal zoomLevel () const

Signals

void centered ( const QGeoCoordinate & coordinate )
void mapTypeChanged ( MapType mapType )
void zoomLevelChanged ( qreal zoomLevel )

Protected Functions

void resizeEvent ( QGraphicsSceneResizeEvent * event )

Detailed Description

The QGeoMapWidget class is used to display a map and manager the interactions between the user and the map.

Most of the functionality is provided by QGeoMappingManager, which handles most aspects of the display.

The map viewport can be panned, the zoom level can be changed and the center coordinate of the viewport can be set explicitly.

The screenPositionToCoordinate() and coordinateToScreenPoisition() functions can be used to convert between positions on the screen and global coordinates.

Mouse and keyboard events should be handled by subclassing QGeoMapWidget and providing implementations of the event handling functions present in QGraphicsWidget.


Member Type Documentation

enum QGeoMapWidget::MapType

Describes a type of map data.

ConstantValueDescription
QGeoMapWidget::NoMap0Indicates a lack of map valid data.
QGeoMapWidget::StreetMap1The map data is a graphical representation of streets and building boundaries.
QGeoMapWidget::SatelliteMapDay2The map data is composed of images collected by satellites during the daytime.
QGeoMapWidget::SatelliteMapNight3The map data is composed of images collected by satellites during the nighttime.
QGeoMapWidget::TerrainMap4The map data is a graphical representation of terrain features. This may also include some of the information provided by QGeoMapWidget::StreetMap.

Member Function Documentation

QGeoMapWidget::QGeoMapWidget ( QGeoMappingManager * manager, QGraphicsItem * parent = 0 )

Creates a new mapping widget, with the mapping operations managed by manager, and the specified parent.

Note that the manager will typically be accessed from an instance of QGeoServiceProvider:

 QGeoServiceProvider serviceProvider("nokia");
 QGeoMappingManager *manager = serviceProvider.mappingManager();
 QGeoMapWidget *widget = new QGeoMapWidget(manager);

QGeoMapWidget::~QGeoMapWidget () [virtual]

Destroys this map widget.

void QGeoMapWidget::addMapObject ( QGeoMapObject * mapObject )

Adds mapObject to the list of map objects managed by this widget.

If mapObject is within the viewport of the map and QGeoMapObject::isVisible() returns true then the map will display the map object immediately.

The widget will take ownership of the mapObject.

QGeoCoordinate QGeoMapWidget::center () const

Returns the coordinate of the point in the center of the map viewport.

See also setCenter().

void QGeoMapWidget::centered ( const QGeoCoordinate & coordinate ) [signal]

Indicates that the map has been centered on coordinate.

This signal will not be emitted when the user pans the map.

QPointF QGeoMapWidget::coordinateToScreenPosition ( const QGeoCoordinate & coordinate ) const

Returns the position on the screen at which coordinate is displayed.

An invalid QPointF will be returned if coordinate is invalid or is not within the current viewport.

QList<QGeoMapObject *> QGeoMapWidget::mapObjects ()

Returns the list of map objects managed by this widget.

QList<QGeoMapObject *> QGeoMapWidget::mapObjectsAtScreenPosition ( const QPointF & screenPosition )

Returns the list of map objects managed by this widget which are visible and contain the point screenPosition within their boundaries.

QList<QGeoMapObject *> QGeoMapWidget::mapObjectsInScreenRect ( const QRectF & screenRect )

Returns the list of map objects managed by this widget which are visible and which are displayed at least partially within the on screen rectangle screenRect.

MapType QGeoMapWidget::mapType () const

Returns the type of map data which is being displayed.

See also setMapType().

void QGeoMapWidget::mapTypeChanged ( MapType mapType ) [signal]

Indicates that the type of the map has been changed.

qreal QGeoMapWidget::maximumZoomLevel () const

Returns the maximum zoom level supported by the QGeoMappingManager associated with this widget.

Larger values of the zoom level correspond to more detailed views of the map.

qreal QGeoMapWidget::minimumZoomLevel () const

Returns the minimum zoom level supported by the QGeoMappingManager associated with this widget.

Larger values of the zoom level correspond to more detailed views of the map.

void QGeoMapWidget::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * parent )

void QGeoMapWidget::pan ( int dx, int dy )

Pans the map view dx pixels in the x direction and dy pixels in they y direction.

The x and y axes are specified in Graphics View Framework coordinates. By default this will mean that positive values of dx move the viewed area to the right and that positive values of dy move the viewed area down.

void QGeoMapWidget::removeMapObject ( QGeoMapObject * mapObject )

Removes mapObject from the list of map objects managed by this widget.

If mapObject is within the viewport of the map and QGeoMapObject::isVisible() returns true then the map will stop displaying the map object immediately.

The widget will release ownership of the mapObject.

void QGeoMapWidget::resizeEvent ( QGraphicsSceneResizeEvent * event ) [protected]

QGeoCoordinate QGeoMapWidget::screenPositionToCoordinate ( QPointF screenPosition ) const

Returns the coordinate corresponding to the point in the viewport at screenPosition.

An invalid QGeoCoordinate will be returned if screenPosition is invalid or is not within the current viewport.

void QGeoMapWidget::setCenter ( const QGeoCoordinate & center )

Centers the map viewport on the coordinate center.

See also center().

void QGeoMapWidget::setMapType ( MapType mapType )

Changes the type of map data to display to mapType.

This will do nothing if mapType is not present in supportedMapTypes().

See also mapType().

void QGeoMapWidget::setZoomLevel ( qreal zoomLevel )

Sets the zoom level of the map to zoomLevel.

Larger values of the zoom level correspond to more detailed views of the map.

If zoomLevel is less than minimumZoomLevel() then minimumZoomLevel() will be used, and if zoomLevel is larger than maximumZoomLevel() then maximumZoomLevel() will be used.

See also zoomLevel().

QPainterPath QGeoMapWidget::shape () const

void QGeoMapWidget::startPanning ()

void QGeoMapWidget::stopPanning ()

QList<MapType> QGeoMapWidget::supportedMapTypes () const

Returns the map types supported by the QGeoMappingManager associated with this widget.

QList<QGeoMapObject *> QGeoMapWidget::visibleMapObjects ()

Returns the list of map objects managed by this widget which are currently visible and at least partially within the viewport of the map.

qreal QGeoMapWidget::zoomLevel () const

Returns the zoom level of the map.

Larger values of the zoom level correspond to more detailed views of the map.

See also setZoomLevel().

void QGeoMapWidget::zoomLevelChanged ( qreal zoomLevel ) [signal]

Indicates that the zoom level has changed to zoomLevel.


Copyright © 2009-2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Mobility Project 1.1.0