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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

MapQuickItem

The MapQuickItem element displays an arbitrary Qt Quick element on a Map. More...

Inherits Item

This type was introduced in Qt Location 5.0.

Properties

Detailed Description

The MapQuickItem element is used to place an arbitrary Qt Quick element on a Map at a specified location and size. Compared to floating an item above the Map, a MapQuickItem will follow the panning (and optionally, the zooming) of the Map as if it is on the Map surface.

The sourceItem property contains the Qt Quick item to be drawn, which can be any kind of visible element.

Positioning and Sizing

The positioning of the MapQuickItem on the Map is controlled by two properties: coordinate and anchorPoint. If only coordinate is set, it specifies a longitude/latitude coordinate for the item to be placed at. The set coordinate will line up with the top-left corner of the contained item when shown on the screen.

The anchorPoint property provides a way to line up the coordinate with other parts of the item than just the top-left corner, by setting a number of pixels the item will be offset by. A simple way to think about it is to note that the point given by anchorPoint on the item itself is the point that will line up with the given coordinate when displayed.

In addition to being anchored to the map, the MapQuickItem can optionally follow the scale of the map, and change size when the Map is zoomed in or zoomed out. This behaviour is controlled by the zoomLevel property. The default behaviour if zoomLevel is not set is for the item to be drawn "on the screen" rather than "on the map", so that its size remains the same regardless of the zoom level of the Map.

Interaction

MapQuickItem is different to the other map object elements in that it can accept "normal" QtQuick mouse and touch interaction elements as well as the MapMouseArea and friends. For example, for a MapQuickItem, the following two situations are equivalent:

 MapQuickItem {
     sourceItem: Rectangle {
         width: 20; height: 20
     }

     MapMouseArea {
         onClicked: {
             console.log("clicked!");
         }
     }
 }
 MapQuickItem {
     sourceItem: Rectangle {
         width: 20; height: 20

         MouseArea {
             onClicked: {
                 console.log("clicked!");
             }
         }
     }
 }

Note, however, that using a MapMouseArea inside the sourceItem (in this case, inside the Rectangle element), is unsupported, and may not work as desired.

MouseAreas used inside a complex sourceItem can be used to create, for example, a "close" button within a speech bubble that can be clicked separately to the rest of the bubble, which would be impossible using MapMouseArea alone.

Performance

Performance of a MapQuickItem is normally in the same ballpark as the contained Qt Quick item alone. Overheads added amount to a translation and (possibly) scaling of the original item, as well as a transformation from longitude and latitude to screen position.

Limitations

Note: Due to an implementation detail, items placed inside a MapQuickItem will have a parent item which is not the MapQuickItem. Refer to the MapQuickItem by its id, and avoid the use of anchor in the sourceItem.

Example Usage

The following snippet shows a MapQuickItem containing an Image element, to display a Marker on the Map. This strategy is used to show the map markers in the MapViewer example.

 MapQuickItem {
     id: marker
     anchorPoint.x: image.width/4
     anchorPoint.y: image.height

     coordinate: Coordinate { latitude : 0; longitude : 0 }

     sourceItem: Image {
         id: image
     }
 }

Property Documentation

anchorPoint : QPointF

This property determines which point on the sourceItem that will be lined up with the coordinate on the map.


coordinate : Coordinate

This property holds the anchor coordinate of the MapQuickItem. The point on the sourceItem that is specified by anchorPoint is kept aligned with this coordinate when drawn on the map.

In the image below, there are 3 MapQuickItems that are identical except for the value of their anchorPoint properties. The values of anchorPoint for each are written on top of the item.


sourceItem : object

This property holds the source item that will be drawn on the map.


zoomLevel : qreal

This property controls the scaling behaviour of the contents of the MapQuickItem. In particular, by setting this property it is possible to choose between objects that are drawn on the screen (and sized in screen pixels), and those drawn on the map surface (which change size with the zoom level of the map).

The default value for this property is 0.0, which corresponds to drawing the object on the screen surface. If set to another value, the object will be drawn on the map surface instead. The value (if not zero) specifies the zoomLevel at which the object will be visible at a scale of 1:1 (ie, where object pixels and screen pixels are the same). At zoom levels lower than this, the object will appear smaller, and at higher zoom levels, appear larger. This is in contrast to when this property is set to zero, where the object remains the same size on the screen at all zoom levels.


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 5.0-snapshot
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