Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

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

    read-onlycenter : 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.


    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.

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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
    • 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.


    read-onlymaximumZoomLevel : qreal

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

    This documentation was introduced in Qt Mobility Mobility 1.2.


    read-onlyminimumZoomLevel : qreal

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

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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.

    This documentation was introduced in Qt Mobility Mobility 1.2.


    read-onlysize : QSizeF

    This property holds the size of the map viewport.

    This documentation was introduced in Qt Mobility Mobility 1.2.


    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.

    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.


    Publicité

    Best Of

    Actualités les plus lues

    Semaine
    Mois
    Année
    1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 102
    2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
    3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 74
    4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 28
    5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
    6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
    7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
    Page suivante
    1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
    2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
    3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
    4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
    5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
    6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 102
    7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
    Page suivante

    Le Qt Developer Network au hasard

    Logo

    Applications mobiles modernes avec Qt et QML

    Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

    Communauté

    Ressources

    Liens utiles

    Contact

    • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

    Qt dans le magazine

    Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.2
    Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
    Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
     
     
     
     
    Partenaires

    Hébergement Web