The Qt Positioning Android plugin wraps native Android APIs and provides access to positioning and satellite information.
The plugin can be loaded by using the provider name android .
The following table lists parameters that can be passed to the Android plugin.
| 参数 | 描述 |
|---|---|
| useMslAltitude |
The parameter is introduced in Qt 6.8. It determines if the plugin will try to provide an altitude above Mean Sea Level (MSL). The default value is
false
, which means that it provides the altitude in WGS84 format. This parameter is only relevant for Android 14 and later. See
Altitude Conversion
章节了解更多细节。
|
Android traditionally provides altitude above the World Geodetic System 1984 (WGS84) reference ellipsoid. However, starting from Android 14, a new AltitudeConverter class was introduced. This class allows to convert the WGS84 altitude into altitude above Mean Sea Level (MSL) 格式。
若
useMslAltitude
plugin parameter is set to
true
, and the application is running on
Android 14
or later, the
QGeoCoordinate::altitude
component of
QGeoPositionInfo
objects retrieved during position updates will contain the MSL altitude.
注意: According to the Android 文档编制 , the conversion to the MSL altitude may take several seconds. It means that lastKnownPosition () requests may execute longer when this feature is enabled, because the method is synchronous. Other position update requests are not affected.
The following examples show how to create an android PositionSource from C++ and QML.
The following snippet creates a PositionSource with no parameters. The altitude will be reported in WGS84 format.
PositionSource { name: "android" }
The next snippet explicitly adds the
useMslAltitude
PluginParameter
and sets its value to
true
。此
PositionSource
will report the altitude in MSL format.
PositionSource { name: "android" PluginParameter { name: "useMslAltitude" value: true } }
The following snippet shows how to use C++ to create a position source which reports the altitude in MSL format.
QVariantMap params; params["useMslAltitude"] = true; QGeoPositionInfoSource *positionSource = QGeoPositionInfoSource::createSource("android", params, this);