QtMobility Reference Documentation

Contents

QML Map Element

The Map element displays a map. More...

  • List of all members, including inherited members
  • 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.

    API break notice: compared to preliminary 1.1 API version, the 1.2 API does not have the objects -property.

    Property Documentation

    center : Coordinate

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

    The default value is an arbitrary valid coordinate.

    This documentation was introduced in Qt Mobility Mobility 1.2.


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

    This documentation was introduced in Qt Mobility Mobility 1.2.


    mapType : enumeration

    This property holds the type of map to display.

    The type can be one of:

    • Map.StreetMap
    • Map.SatelliteMapDay
    • Map.SatelliteMapNight
    • Map.TerrainMap
    • Map.HybridMap
    • Map.TransitMap
    • Map.GrayStreetMap
    • Map.MobileStreetMap
    • Map.MobileTerrainMap
    • Map.MobileHybridMap
    • Map.MobileTransitMap
    • Map.MobileGrayStreetMap

    The default value is determined by the plugin.

    This documentation was introduced in Qt Mobility Mobility 1.2.


    maximumZoomLevel : qreal

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

    This documentation was introduced in Qt Mobility Mobility 1.2.


    minimumZoomLevel : qreal

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

    This documentation was introduced in Qt Mobility Mobility 1.2.


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

    This documentation was introduced in Qt Mobility Mobility 1.2.


    size : QSizeF

    This property holds the size of the map viewport.

    This documentation was introduced in Qt Mobility Mobility 1.2.


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

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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.

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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)
                 }

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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))
         }

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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.

    This documentation was introduced in Qt Mobility Mobility 1.2.