Qt Location

The Qt Location module helps you create mapping solutions using data available from popular location service providers, such as Open Street Map .

Qt Location API 能夠:

  • Access and present map data.
  • Support touch gesture on a specific area of the map.
  • Query for a specific geographical location and route.
  • Add additional layers on top, such as polylines and circles.
  • Search for places and related images.

使用模塊

QML API

To use the types, add the following import statements to your .qml 文件:

import QtPositioning
import QtLocation
					

注意: Many Qt Location QML module APIs are using types from the Qt Positioning module. For example, defining a coordinate to be the center of the map requires types from the Qt Positioning module.

C++ API

For C++ projects, include the header appropriate for the current use case; for example, applications using routes may use:

#include <QGeoRoute>
					

使用 Qt 模塊的 C++ API 要求直接 (或透過其它依賴) 鏈接到模塊庫。幾個構建工具對此有專用支持,包括 CMake and qmake .

構建采用 CMake

使用 find_package() 命令定位所需模塊組件在 Qt6 包:

find_package(Qt6 REQUIRED COMPONENTS Location)
target_link_libraries(mytarget PRIVATE Qt6::Location)
					

更多細節,見 構建采用 CMake 概述。

采用 qmake 構建

要配置采用 qmake 構建模塊,添加模塊作為值為 QT 變量在工程的 .pro 文件:

QT += location
					

子模塊

The API is split into sub-modules, which provide QML and C++ interfaces for specific purposes. They focus mainly on Map and Place information. The required position data can be retrieved using the QtPositioning 模塊。

Places

The Places submodule is the natural complement to Positioning, providing a source of geographical data about Places of Interest (POI). Besides the source information, the API provides information about the location, size, and other related information about a POI. The Places API can also retrieve images, reviews, and other content related to a place.

Places introduction: for QML for C++

地圖和導航

The module provides the QML and C++ alternatives for maps and navigation. The C++ alternative provides utility classes to get geocoding (finding a geographic coordinate from a street address) and navigation (including driving and walking directions) information, whereas its QML counterpart provides UI components to render the information.

Maps and Navigation introduction: for QML for C++

範例

範例 App Examples demonstrating use of the Qt Location APIs
地圖和導航教程 Tutorial introducing the QML Maps Types

API 參考

The following are lists of the classes and UI components provided by the module, with example applications to demonstrate their usage:

QML API 參考 Full list of QML components in the Qt Location API
C++ API 參考按領域 Full list of C++ classes and methods of the Qt Location APIs sorted by domain
C++ API 參考 Full list of C++ classes and methods of the Qt Location APIs

插件參考和參數

Information about plugins, important notes on their usage, parameters that can be provided to influence their behavior.

Qt Location Items Overlay Plugin

Provides an empty map intended to be used as background for an overlay layers for map items.

Qt Location 開放式街道地圖插件

Uses Open Street Map and related services.

實現新的後端和移植

For systems integrators and distributors, information related to making Qt Location available for a new platform.

GeoServices Information about the Qt Location GeoServices plugins
Places Information for places backend implementors
API 變化 Information about porting from Qt 5 to Qt 6

許可

Qt Location 在商業許可下是可用的來自 Qt 公司 。此外,它是可用的根據 GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。