C

Map QML Type

The Map type displays a map. More...

Import Statement: import QtLocation
Since: Qt Quick Ultralite 2.10

Properties

Methods

  • void pan(int dx, int dy)

Detailed Description

The Map type is used to display a map or image of the Earth.

There are a variety of different ways to visualize the Earth's surface in a two-dimensional manner, but all of them involve some kind of projection: a mathematical relationship between the 3D coordinates (latitude, longitude) and 2D coordinates (X and Y in pixels) on the screen. The Map type assumes that the map data uses Pseudo-Mercator projection EPSG:3857.

The user has to provide an implementation of Qul::MapTileFetcher which the Map type consumes to access the generated map images. See Map tile fetcher integration for more infromation.

The geographic region displayed in the Map item is referred to as its viewport, and it's defined by center and zoomLevel properties. The center property contains a geoCoordinate specifying the center of the viewport, while zoomLevel controls the scale of the map. See each of these properties for further details about their values.

Example Usage

The following snippet shows a simple Map. The map is centered over Oulu, Finland, with zoom level 17.

import QtQuick
import QtPositioning
import QtLocation

Rectangle {
    id: root

    property real zoomLevel: 17

    Map {
        id: map

        anchors.fill: parent
        center {
            latitude: 65.011762
            longitude: 25.470841
        }
        zoomLevel: root.zoomLevel
        minimumZoomLevel: 10
        maximumZoomLevel: 18
    }
}

Property Documentation

bearing : real

This property holds the bearing for the map.

The default value is 0.


center : geoCoordinate

This property holds the coordinate which occupies the center of the mapping viewport. Invalid center coordinates are ignored. The coordinate values should be specified using the WGS84 datum.

The default value is an arbitrary valid coordinate.


maximumZoomLevel : real

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

The default value is 23.


minimumZoomLevel : real

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

The default value is 0.


zoomLevel : real

This property holds the zoom level for the map.

Larger values for the zoom level provide more detail. Zoom levels are always non-negative. The default value is 8.0. Values outside the [minimumZoomLevel, maximumZoomLevel] range, which represent the range for which tiles are available, will be clamped.


Method Documentation

void pan(int dx, int dy)

Starts panning the map by dx pixels along the x-axis and by dy pixels along the y-axis.

Positive values for dx move the map right, negative values move the map left. Positive values for dy move the map down, negative values move the map up.

During panning the center and zoomLevel may change.


Available under certain Qt licenses.
Find out more.