QGeoServiceProvider Class

QGeoServiceProvider 类汇集了对提供地理信息的服务的访问。更多

Header: #include <QGeoServiceProvider>
qmake: QT += location
Inherits: QObject

公共类型

enum Error { NoError, NotSupportedError, UnknownParameterError, MissingRequiredParameterError, ConnectionError, LoaderError }
enum GeocodingFeature { NoGeocodingFeatures, OnlineGeocodingFeature, OfflineGeocodingFeature, ReverseGeocodingFeature, LocalizedGeocodingFeature, AnyGeocodingFeatures }
flags GeocodingFeatures
enum MappingFeature { NoMappingFeatures, OnlineMappingFeature, OfflineMappingFeature, LocalizedMappingFeature, AnyMappingFeatures }
flags MappingFeatures
enum NavigationFeature { NoNavigationFeatures, OnlineNavigationFeature, OfflineNavigationFeature, AnyNavigationFeatures }
flags NavigationFeatures
enum PlacesFeature { NoPlacesFeatures, OnlinePlacesFeature, OfflinePlacesFeature, SavePlaceFeature, RemovePlaceFeature, …, AnyPlacesFeatures }
flags PlacesFeatures
enum RoutingFeature { NoRoutingFeatures, OnlineRoutingFeature, OfflineRoutingFeature, LocalizedRoutingFeature, RouteUpdatesFeature, …, AnyRoutingFeatures }
flags RoutingFeatures

公共函数

QGeoServiceProvider(const QString &providerName, const QVariantMap &parameters = QVariantMap(), bool allowExperimental = false)
virtual ~QGeoServiceProvider()
QGeoServiceProvider::Error error() const
QString errorString() const
QGeoServiceProvider::Error geocodingError() const
QString geocodingErrorString() const
QGeoServiceProvider::GeocodingFeatures geocodingFeatures() const
QGeoCodingManager *geocodingManager() const
QGeoServiceProvider::Error mappingError() const
QString mappingErrorString() const
QGeoServiceProvider::MappingFeatures mappingFeatures() const
QGeoServiceProvider::Error navigationError() const
QString navigationErrorString() const
(since QtLocation 5.11) QGeoServiceProvider::NavigationFeatures navigationFeatures() const
QPlaceManager *placeManager() const
QGeoServiceProvider::Error placesError() const
QString placesErrorString() const
QGeoServiceProvider::PlacesFeatures placesFeatures() const
QGeoServiceProvider::Error routingError() const
QString routingErrorString() const
QGeoServiceProvider::RoutingFeatures routingFeatures() const
QGeoRoutingManager *routingManager() const
void setAllowExperimental(bool allow)
void setLocale(const QLocale &locale)
void setParameters(const QVariantMap &parameters)

静态公共成员

详细说明

地图与导航应用程序接口(Maps and Navigation API)允许人们访问各种地理信息,包括执行地理编码、路由选择和显示地图的功能。QGeoServiceProvider 集合了对由单一供应商提供的这些服务的访问。

不同领域的服务提供商可以混搭使用,这样一个服务提供商的地理编码管理器就可以与另一个服务提供商的地理路由管理器一起使用。

除非客户能验证不同服务提供的数据是兼容的,否则不建议这样做,因为底层数据集的差异可能会导致服务之间严重不协调。

QGeoServiceProvider 的子类可保证其提供的不同服务具有互操作性。

每个服务提供者都必须遵循服务特定参数名称/键的命名约定。它们使用提供程序名称作为所有参数名称的前缀。在加载服务提供商时,只有那些参数名以提供商名称开头的参数才会被传递。这就避免了与其他插件共享敏感参数,如机密tokenapp_id 参数。

请查看 GeoServices 插件特定文档,以获取可用参数名/键和值的完整列表。

成员类型文档

enum QGeoServiceProvider::Error

描述与加载和设置服务提供商插件有关的错误。

常量说明
QGeoServiceProvider::NoError0未发生错误。
QGeoServiceProvider::NotSupportedError1插件不支持此功能。
QGeoServiceProvider::UnknownParameterError2插件无法识别其中一个参数。
QGeoServiceProvider::MissingRequiredParameterError3插件未找到预期参数。
QGeoServiceProvider::ConnectionError4插件无法连接其后台服务或数据库。
QGeoServiceProvider::LoaderError5插件加载失败。

枚举 QGeoServiceProvider::GeocodingFeature
标志 QGeoServiceProvider::GeocodingFeatures

描述地理服务提供商支持的地理编码功能。

常量描述
QGeoServiceProvider::NoGeocodingFeatures0不支持地理编码功能。
QGeoServiceProvider::OnlineGeocodingFeature(1<<0)支持在线地理编码。
QGeoServiceProvider::OfflineGeocodingFeature(1<<1)支持离线地理编码。
QGeoServiceProvider::ReverseGeocodingFeature(1<<2)支持反向地理编码。
QGeoServiceProvider::LocalizedGeocodingFeature(1<<3)支持返回带有本地化地址的地理编码结果。
QGeoServiceProvider::AnyGeocodingFeatures~(0)匹配提供任何地理编码功能的地理服务提供商。

GeocodingFeatures 类型是QFlags<GeocodingFeature> 的类型定义。它存储 GeocodingFeature 值的 OR 组合。

枚举 QGeoServiceProvider::MappingFeature
flags QGeoServiceProvider::MappingFeatures

描述地理服务提供者支持的映射特征。

常量描述
QGeoServiceProvider::NoMappingFeatures0不支持映射功能。
QGeoServiceProvider::OnlineMappingFeature(1<<0)支持在线映射。
QGeoServiceProvider::OfflineMappingFeature(1<<1)支持离线映射。
QGeoServiceProvider::LocalizedMappingFeature(1<<2)支持返回本地化地图数据。
QGeoServiceProvider::AnyMappingFeatures~(0)匹配提供任何地图功能的地理服务提供商。

MappingFeatures 类型是QFlags<MappingFeature> 的类型定义。它存储 MappingFeature 值的 OR 组合。

描述地理服务提供者支持的导航功能。

常量描述
QGeoServiceProvider::NoNavigationFeatures0不支持导航功能。
QGeoServiceProvider::OnlineNavigationFeature(1<<0)支持在线导航。
QGeoServiceProvider::OfflineNavigationFeature(1<<1)支持离线导航。
QGeoServiceProvider::AnyNavigationFeatures~(0)匹配提供任何导航功能的地理服务提供商。

NavigationFeatures 类型是QFlags<NavigationFeature> 的类型定义。它存储导航特征值的 OR 组合。

枚举 QGeoServiceProvider::PlacesFeature
flags QGeoServiceProvider::PlacesFeatures

描述地理服务提供者支持的地点特征。

常量描述
QGeoServiceProvider::NoPlacesFeatures0不支持地点功能。
QGeoServiceProvider::OnlinePlacesFeature(1<<0)支持在线地点。
QGeoServiceProvider::OfflinePlacesFeature(1<<1)支持离线位置。
QGeoServiceProvider::SavePlaceFeature(1<<2)支持保存位置。
QGeoServiceProvider::RemovePlaceFeature(1<<3)支持移除或删除地点。
QGeoServiceProvider::SaveCategoryFeature(1<<4)支持保存类别。
QGeoServiceProvider::RemoveCategoryFeature(1<<5)支持移除或删除类别。
QGeoServiceProvider::PlaceRecommendationsFeature(1<<6)支持搜索与另一地点相似的推荐地点。
QGeoServiceProvider::SearchSuggestionsFeature(1<<7)支持搜索建议。
QGeoServiceProvider::LocalizedPlacesFeature(1<<8)支持返回本地化地点数据。
QGeoServiceProvider::NotificationsFeature(1<<9)支持地点和类别变更通知。
QGeoServiceProvider::PlaceMatchingFeature(1<<10)支持匹配来自两个不同地理服务提供商的地点。
QGeoServiceProvider::AnyPlacesFeatures~(0)匹配提供任何地点特征的地理服务提供商。

PlacesFeatures 类型是QFlags<PlacesFeature> 的类型定义。它存储 PlacesFeature 值的 OR 组合。

枚举 QGeoServiceProvider::RoutingFeature
flags QGeoServiceProvider::RoutingFeatures

描述地理服务提供者支持的路由特性。

常量描述
QGeoServiceProvider::NoRoutingFeatures0不支持路由功能。
QGeoServiceProvider::OnlineRoutingFeature(1<<0)支持在线路由。
QGeoServiceProvider::OfflineRoutingFeature(1<<1)支持离线路由。
QGeoServiceProvider::LocalizedRoutingFeature(1<<2)支持返回带有本地化地址和说明的路线。
QGeoServiceProvider::RouteUpdatesFeature(1<<3)支持根据当前位置更新现有路线。
QGeoServiceProvider::AlternativeRoutesFeature(1<<4)支持返回备选路线。
QGeoServiceProvider::ExcludeAreasRoutingFeature(1<<5)支持指定返回路线不得穿越的区域。
QGeoServiceProvider::AnyRoutingFeatures~(0)匹配提供任何路线功能的地理服务提供商。

RoutingFeatures 类型是QFlags<RoutingFeature> 的类型定义。它存储 RoutingFeature 值的 OR 组合。

成员函数文档

QGeoServiceProvider::QGeoServiceProvider(const QString &providerName, const QVariantMap &parameters = QVariantMap(), bool allowExperimental = false)

使用提供的parameters ,构造一个后端名称为providerName 的 QGeoServiceProvider。

如果多个插件具有相同的providerName ,则将使用报告的 providerVersion() 最高的插件。

如果allowExperimental 为 true,则可使用标记为实验性的插件。默认情况下不考虑实验性插件。

如果无法加载与providerName 匹配的插件,那么error() 和errorString() 将提供详细原因。

注意: 在将parameters 列表传递给待加载的提供程序插件之前,会对该列表进行过滤,以避免与不相关的提供程序插件共享插件特定参数。插件特定参数键必须以提供程序名称为前缀(例如here.app_id )。

[virtual noexcept] QGeoServiceProvider::~QGeoServiceProvider()

销毁服务提供商对象。

[static] QStringList QGeoServiceProvider::availableServiceProviders()

返回可用服务提供商名称列表,供QGeoServiceProvider 构造函数使用。

QGeoServiceProvider::Error QGeoServiceProvider::error() const

返回错误代码,说明该类最后一次执行操作时发生的错误。

QString QGeoServiceProvider::errorString() const

返回一个字符串,说明该类最后一次执行操作时发生的错误。

QGeoServiceProvider::Error QGeoServiceProvider::geocodingError() const

返回错误代码,说明上次尝试创建地理编码管理器时发生的错误。

QString QGeoServiceProvider::geocodingErrorString() const

返回一个字符串,说明上次尝试创建地理编码管理器时发生的错误。

QGeoServiceProvider::GeocodingFeatures QGeoServiceProvider::geocodingFeatures() const

返回地理服务提供商支持的地理编码特征。

QGeoCodingManager *QGeoServiceProvider::geocodingManager() const

返回服务提供商提供的QGeoCodingManager

如果服务提供商不提供任何地理编码服务,则此函数将返回nullptr

首次调用此函数时,将尝试构建一个QGeoCodingManager 实例。如果尝试成功,将缓存QGeoCodingManager ,否则每次调用此函数都将尝试构建一个QGeoCodingManager 实例,直到构建成功为止。

QGeoCodingManagerQGeoServiceProvider 所有,不应单独删除。用户应假定删除QGeoServiceProvider 会导致本方法返回的指针无效。

调用此函数后,error() 和errorString() 将报告在构建QGeoCodingManager 时发生的任何错误。

QGeoServiceProvider::Error QGeoServiceProvider::mappingError() const

返回错误代码,说明上次尝试创建映射管理器时发生的错误。

QString QGeoServiceProvider::mappingErrorString() const

返回一个字符串,说明上次尝试创建映射管理器时发生的错误。

QGeoServiceProvider::MappingFeatures QGeoServiceProvider::mappingFeatures() const

返回地理服务提供商支持的地图功能。

返回错误代码,说明上次尝试创建导航管理器时发生的错误。

返回一个字符串,说明上次尝试创建导航管理器时发生的错误。

返回地理服务提供商支持的导航功能。

此函数在 QtLocation 5.11 中引入。

QPlaceManager *QGeoServiceProvider::placeManager() const

返回服务提供商提供的QPlaceManager

首次调用此函数时,将尝试构建一个QPlaceManager 实例。如果尝试成功,该QPlaceManager 将被缓存,否则每次调用该函数都将尝试构建一个QPlace 实例,直到构建成功为止。

QGeoPlaceManager 为QGeoServiceProvider 所有,不应单独删除。用户应假定删除QGeoServiceProvider 会导致本方法返回的指针无效。

调用此函数后,error() 和errorString() 将报告在构建QPlaceManager 时发生的任何错误。

QGeoServiceProvider::Error QGeoServiceProvider::placesError() const

返回错误代码,说明上次尝试创建位置管理器时发生的错误。

QString QGeoServiceProvider::placesErrorString() const

返回一个字符串,说明上次尝试创建位置管理器时发生的错误。

QGeoServiceProvider::PlacesFeatures QGeoServiceProvider::placesFeatures() const

返回地理服务提供商支持的地点特征。

QGeoServiceProvider::Error QGeoServiceProvider::routingError() const

返回错误代码,说明上次尝试创建路由管理器时发生的错误。

QString QGeoServiceProvider::routingErrorString() const

返回一个字符串,说明上次尝试创建路由管理器时发生的错误。

QGeoServiceProvider::RoutingFeatures QGeoServiceProvider::routingFeatures() const

返回地理服务提供商支持的路由功能。

QGeoRoutingManager *QGeoServiceProvider::routingManager() const

返回服务提供商提供的QGeoRoutingManager

如果服务提供商不提供任何地理路由服务,则此函数将返回nullptr

首次调用此函数时,将尝试构建一个QGeoRoutingManager 实例。如果尝试成功,将缓存QGeoRoutingManager ,否则每次调用此函数都将尝试构建一个QGeoRoutingManager 实例,直到构建成功为止。

QGeoRoutingManagerQGeoServiceProvider 所有,不应单独删除。用户应假定删除QGeoServiceProvider 会导致本方法返回的指针无效。

调用此函数后,error() 和errorString() 将报告在构建QGeoRoutingManager 时发生的任何错误。

void QGeoServiceProvider::setAllowExperimental(bool allow)

设置在为此服务提供商查找正确插件库时是否考虑实验插件,网址为allow

重要:这将销毁此服务提供商实例持有的任何现有管理器。在调用此方法后,请确保不要尝试使用之前获取的任何指针。

void QGeoServiceProvider::setLocale(const QLocale &locale)

将此服务提供商使用的地域设置为locale 。如果具有相关功能(请参阅LocalizedMappingFeature 等),这将更改提供商数据的语言、单位和其他特定于地域的属性。

void QGeoServiceProvider::setParameters(const QVariantMap &parameters)

将用于为该服务提供商构建单个管理器类的参数设置为parameters

在将parameters 列表传递给待加载的服务提供商之前,会对该列表进行过滤,以避免与不相关的服务提供商共享提供商特定参数。提供商特定参数键必须以提供商名称为前缀(如here.app_id )。

重要:这将销毁该服务提供商实例持有的任何现有管理器。在调用此方法后,请确保不要尝试使用以前检索到的任何指针。

© 2025 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.