QtMobility Reference Documentation

QML Map Element

The Map element displays a map. More...

Properties

Methods

Detailed Description

The Map element can be used be used to display a map of the world. The bulk of the functionality is provided by a mapping plugin described by the Plugin element associated with the Map.

Various map objects can be added to the map. These map objects are specified in terms of coordinates and metres.

MapObjects can be directly added to the Map element and it will display them automatically. The various objects that can be added include:

Of the above list, MapObjectView is a special case and not a MapObject as such. Here is a small example to illustrate this:

 Map {
     id: map
     plugin : Plugin {name : "nokia"}
     anchors.fill: parent
     size.width: parent.width
     size.height: parent.height
     zoomLevel: 10

     MapObjectView {
         id: allLandmarks
         model: landmarkModelAll
         delegate: Component {
             MapCircle {
                 color: "green"
                 radius: 1000
                 center: Coordinate {
                     latitude: landmark.coordinate.latitude
                     longitude: landmark.coordinate.longitude
                 }
             }
         }
     }

     MapCircle {
         id: myPosition
         color: "yellow"
         radius: 1000
         center: myPositionSource.position.coordinate
     }

Mouse handling is done by adding MapMouseArea items as children of either MapObjects or the Map item itself.

The Map element is part of the QtMobility.location 1.2 module.

Property Documentation

read-onlycenter : Coordinate

This property holds the coordinate which occupies the center of the mapping viewport.

The default value is an arbitrary valid coordinate.


read-onlyconnectivityMode : enumeration

This property holds the connectivity mode used to fetch the map data.

The mode can be one of:

  • Map.OfflineMode
  • Map.OnlineMode
  • Map.HybridMode

The default value is determined by the plugin.


read-onlymapType : enumeration

This property holds the type of map to display.

The type can be one of:

  • Map.StreetMap
  • Map.SatelliteMapDay
  • Map.SatelliteMapNight
  • Map.TerrainMap

The default value is determined by the plugin.


read-onlymaximumZoomLevel : qreal

This property holds the maximum valid zoom level for the map.


read-onlyminimumZoomLevel : qreal

This property holds the minimum valid zoom level for the map.


read-onlydefaultobjects : list<QGeoMapObject>

This property holds the list of objects associated with this map.

The various objects that can be added include:


read-onlyplugin : Plugin

This property holds the plugin which provides the mapping functionality.

This is write-once property. Once the map has a plugin associated with it any attempted modifications of the plugin will be ignored.


size : QSizeF

This property holds the size of the map viewport.


read-onlyzoomLevel : qreal

This property holds the zoom level for the map.

Larger values for the zoom level provide more detail.

The default value is 8.0.


Method Documentation

Map::addMapObject ( MapObject )

Adds the given MapOject to the Map. If the object already is on the Map, it will not be added again.

As an example, consider you have a MapCircle presenting your current position:

 MapCircle {
     id: myPositionMarker
     center: myPositionSource.position.coordinate
     radius: 100
     color: "yellow"
 }

You can add it to Map (alterntively it can be defined as a child element of the Map):

 onButton2Clicked: {
     map.addMapObject(myPositionMarker)
 }

Note: MapObjectViews can not be added with this method.


Map::removeMapObject ( MapObject )

Removes the given MapObject from the Map. If the MapObject does not exist, function does nothing.

As an example, consider you have a MapCircle presenting your current position:

 MapCircle {
     id: myPositionMarker
     center: myPositionSource.position.coordinate
     radius: 100
     color: "yellow"
 }

You can remove it from the Map element:

 onButton1Clicked: {
     map.removeMapObject(myPositionMarker)
 }

Map::toCoordinate ( QPointF screenPosition )

Returns the coordinate which corresponds to the screen position screenPosition.

Returns an invalid coordinate if screenPosition is not within the current viewport.

An example to constraint landmarks of a model to just those currently on Map:

 LandmarkBoxFilter {
     id: boxFilter
     topLeft: map.toCoordinate(Qt.point(0,0))
     bottomRight: map.toCoordinate(Qt.point(map.width, map.height))
 }

Map::toScreenPosition ( Coordinate coordinate )

Returns the screen position which corresponds to the coordinate coordinate.

Returns an invalid QPointF if coordinate is not within the current viewport.


X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();