Maps and Navigation (QML)
地图和导航(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).
地图和导航提供QtQuick用户界面类型,用于在地图上显示地理信息,并允许用户与地图覆盖对象和显示本身进行交互。它还包含用于地理编码(从街道地址查找地理坐标)和导航(包括驾驶和步行方向)的实用程序。
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.
为了进行导航,我们需要从起点到目的地的路线。这些路线由分段组成,其中每个路线分段都可以被视为一个导航子任务;例如,“行驶100米”或“左转”。每段的起点和终点都是一个航点,即旅程的一部分。
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.
API的典型用例是用户寻找特定类型的场所,例如餐馆;用户在地图应用程序中输入搜索字符串,并显示设备“附近”餐馆的结果列表。然后,该应用程序可用于使用根据环境中可能有助于或阻碍旅程的特征优化的路线导航到所选目的地。然后,导航继续进行,通过当前位置监视用户的进度。
The types build upon the API concepts and types in the QML Positioning API. A more hands-on introduction of the Maps and Navigation types can be found in the Maps and Navigation tutorial.
类型建立在API概念和QML定位API中的类型之上。在地图和导航教程中可以找到地图和导航类型的更多实践介绍。
Maps
地图
Displaying Maps
显示地图
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.
使用map QML类型显示地图。Map类型支持用户通过MapView QML类型进行交互。Map对象使用OpenGL(ES)在屏幕上绘制地图,允许在可用的情况下进行硬件加速渲染。
Key Types
关键类型
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. QtQuick项目用于在屏幕上显示地图。 |
MapView | Interaction helper for panning, flicking and pinch-to-zoom gesture on a Map. 用于在地图上平移、轻击和缩放手势的交互助手。 |
Note that the client must create a Plugin object prior to using a Map type in order to have access to map data to display.
请注意,客户端必须在使用Map类型之前创建Plugin对象,才能访问要显示的地图数据。
Putting Objects on a Map (Map Overlay Objects)
在地图上放置对象(地图覆盖对象)
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.
地图还可以包含地图覆盖对象,用于在其表面显示信息。有一组基本的预定义地图覆盖对象,以及使用MapQuickItem类型实现自定义地图覆盖对象的能力,该类型可以包含任何标准的QtQuick项。
Key Types
关键类型
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. |
Model-View Design with 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.
要根据QtQuick模型的内容(例如ListModel项)自动生成地图覆盖对象,可以使用MapItemView类型。它接受任何地图覆盖对象作为其委托,并且只能在地图中创建。
Key Types
关键类型
MapItemView | Populates a Map with map overlay objects based on the data provided by a model. 根据模型提供的数据,用地图覆盖对象填充地图。 |
Interaction with Map Overlay Objects
与地图叠加对象的交互
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.
影响其在显示器上的外观的地图覆盖对象的属性可以随时更改,许多属性也可以在动画中使用。基于坐标的地图覆盖对象(如MapPolygon和MapPolyline)的动画制作尚不可用。
Geocoding – Address to Coordinate and Vice Versa
地理编码——地址到坐标、坐标到地址
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.
QML中的地理编码查询是使用GeocodeModel类型执行的。对于要协调查询的地址,其查询属性可以设置为address对象或包含要搜索的地址的文本形式的字符串。要执行相反的操作,可以将相同的属性设置为坐标。模型内容中提供了结果。
Key Types
关键类型
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. 用于查询和地理编码结果的结构化地址。 |
Note that the client must create a Plugin object prior to using a GeocodeModel object. This will enable access to geocoding translation services and thus data to display.
请注意,客户端在使用GeocodeModel对象之前必须创建一个插件对象。这将允许访问地理编码翻译服务,从而显示数据。
Routing and Navigation
路线和导航
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.
路线是确定从地图上的一个点到另一个点的可导航路径。给定一张了解有助于或阻碍航行的特征(如桥梁、水道等)的地图,可以构建一系列组成旅程的路段。如果这些路线分段很简单,那么我们可以在分段之间的连接点(路线Neuvers)添加导航信息。
Key Types
关键类型
route | The entire path to be navigated. 整条路都要走。 |
routeSegment | The individual components of a route. 路线的各个组成部分。 |
routeManeuver | The navigation information that joins segments. 连接分段的导航信息。 |
RouteModel | The means of making requests on the backend to supply route information. 在后端发出请求以提供路线信息的方法。 |
Maps and Navigation (C++)Places (C++)
© 2024 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.