Maps and Navigation (QML)
Maps and Navigation provides QtQuick user interface types for displaying geographic information on a map, as well as allowing user interaction with map overlay objects and the display itself. It also contains utilities for geocoding (finding a geographic coordinate from a street address) and navigation (including driving and walking directions).
To perform navigation we need routes from start to destination. These routes are made up of segments, where each routeSegment can be considered a navigation subtask; for example, "drive 100 meters", or "turn left". The beginning and end of each segment is a waypoint, that is, one part of the journey.
A typical use case for the API is a user looking for a particular type of place, such as a restaurant; the user enters a search string into the map application and is presented with a list of results for restaurants "near" the device. The application can then be used to navigate to the chosen destination using a route that is optimized according to features in the environment that may help or hinder the journey. The navigation then proceeds with the user's progress monitored by means of the current location.
Displaying a map is done using the Map QML types. The Map type supports user interaction through the MapView QML type. The Map object draws the map on-screen using OpenGL (ES), allowing for hardware-accelerated rendering where available.
|Plugin||A location-based services plugin provides data including map data which is then displayed in a Map object.|
|Map||QtQuick item to display a map on-screen.|
|MapView||Interaction helper for panning, flicking and pinch-to-zoom gesture on a Map.|
Maps can also contain map overlay objects, which are used to display information on its surface. There is a set of basic pre-defined map overlay objects, as well as the ability to implement custom map overlay objects using the MapQuickItem type, which can contain any standard QtQuick item.
|MapCircle||A geographic circle (all points at a set distance from a center), optionally with a border.|
|MapRectangle||A rectangle whose top left and bottom right points are specified as coordinate types, optionally with a border.|
|MapPolygon||A polygon made of an arbitrary list of coordinates.|
|MapPolyline||A polyline made of an arbitrary list of coordinates.|
|MapQuickItem||Turns any arbitrary QtQuick Item into a map overlay object. MapQuickItem is an enabler for specifying custom map overlay objects.|
To automatically generate map overlay objects based on the contents of a QtQuick model (for example a ListModel item), the MapItemView type is available. It accepts any map overlay object as its delegate, and can only be created within a Map.
|MapItemView||Populates a Map with map overlay objects based on the data provided by a model.|
Properties of map overlay objects that influence their appearance on the display can be changed at any time, and many can also be used in animations. Animating coordinate-based map overlay objects, such as MapPolygon and MapPolyline, is not yet available.
Geocoding is the translation of geographic coordinates into addresses, or vice versa. Such a translation usually involves sending the source data to a server which then performs the translation and returns the results, although some location-based service provider plugins may be able to provide some geocoding functionality without sending data to a remote server. The availability and accuracy of the translation usually depends on the location or address being translated, as different areas of the Earth are mapped to varying degrees of accuracy.
A geocoding query in QML is performed using the GeocodeModel type. For an address-to-coordinate query, its
query property may be set to either an Address object or a string containing the textual form of the address to search for. To perform the reverse, the same property can be set to a coordinate instead. Results are made available in the contents of the model.
|Plugin||A location-based services plugin provides data including geocoding translation results which are exposed to clients via a GeocodeModel.|
|GeocodeModel||Queries the Plugin for geocoding translations and provides access to results via indexes in the model.|
|Address||Structured address for use in queries and results of geocoding.|
Routing is the determination of a navigable path from one point to another on a map. Given a map that is aware of features that aid or hinder navigation, such as bridges, waterways and so on, a series of segments that make up the journey can be constructed. If these routeSegments are simple then we can add navigation information at the connecting points, routeManeuvers, between the segments.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.