QGeoServiceProvider Class

The QGeoServiceProvider class aggregates access to services which provide geographical information. 更多...

头: #include <QGeoServiceProvider>
qmake: QT += location
Since: Qt 5.6
继承: QObject

公共类型

enum Error { NoError, NotSupportedError, UnknownParameterError, MissingRequiredParameterError, ConnectionError }
enum GeocodingFeature { NoGeocodingFeatures, OnlineGeocodingFeature, OfflineGeocodingFeature, ReverseGeocodingFeature, LocalizedGeocodingFeature, AnyGeocodingFeatures }
flags GeocodingFeatures
enum MappingFeature { NoMappingFeatures, OnlineMappingFeature, OfflineMappingFeature, LocalizedMappingFeature, AnyMappingFeatures }
flags MappingFeatures
enum PlacesFeature { NoPlacesFeatures, OnlinePlacesFeature, OfflinePlacesFeature, SavePlaceFeature, ..., AnyPlacesFeatures }
flags PlacesFeatures
enum RoutingFeature { NoRoutingFeatures, OnlineRoutingFeature, OfflineRoutingFeature, LocalizedRoutingFeature, ..., AnyRoutingFeatures }
flags RoutingFeatures

公共函数

QGeoServiceProvider (const QString & providerName , const QVariantMap & 参数 = QVariantMap(), bool allowExperimental = false)
~QGeoServiceProvider ()
Error error () const
QString errorString () const
GeocodingFeatures geocodingFeatures () const
QGeoCodingManager * geocodingManager () const
MappingFeatures mappingFeatures () const
QPlaceManager * placeManager () const
PlacesFeatures placesFeatures () const
RoutingFeatures routingFeatures () const
QGeoRoutingManager * routingManager () const
void setAllowExperimental (bool allow )
void setLocale (const QLocale & locale )
void setParameters (const QVariantMap & 参数 )

静态公共成员

QStringList availableServiceProviders ()

额外继承成员

详细描述

The QGeoServiceProvider class aggregates access to services which provide geographical information.

The Maps and Navigation API allows people to access various kinds of geographical information, including functionality to perform geocoding, routing and the display of maps. The QGeoServiceProvider aggregates the access to a set of these services that are provided by a single vendor.

It is possible to mix and match service providers for the various domains, so that a geocoding manager from one service provider can be used with a geographic routing manager from another service provider.

This is not recommended unless the client is able to verify that the data provided by the different services are compatible, as differences in the underlying data sets could cause serious incongruences between the services.

子类化的 QGeoServiceProvider guarantee that the different services that they provide are interoperable.

At this point there are two GeoServices plugins packaged with Qt. They are accessible using their provider names:

Each service provider must follow a naming convention for their service specific parameter names/keys. They use the provider name as prefix for all their parameter names. For example, the HERE service provider requires the here.app_id parameter. When a provider is loaded only those parameters are passed on whose parameter names start with the provider name. This avoids the sharing sensitive parameters such as confidential token or app_id parameters with other plugins.

Please check the GeoServices plugin specific documentation to obtain a complete list of the available parameter names/keys and values.

成员类型文档编制

enum QGeoServiceProvider:: Error

Describes an error related to the loading and setup of a service provider plugin.

常量 描述
QGeoServiceProvider::NoError 0 没有出现错误。
QGeoServiceProvider::NotSupportedError 1 The plugin does not support this functionality.
QGeoServiceProvider::UnknownParameterError 2 The plugin did not recognize one of the parameters it was given.
QGeoServiceProvider::MissingRequiredParameterError 3 The plugin did not find one of the parameters it was expecting.
QGeoServiceProvider::ConnectionError 4 The plugin could not connect to its backend service or database.

enum QGeoServiceProvider:: GeocodingFeature
flags QGeoServiceProvider:: GeocodingFeatures

Describes the geocoding features supported by the geo service provider.

常量 描述
QGeoServiceProvider::NoGeocodingFeatures 0 No geocoding features are supported.
QGeoServiceProvider::OnlineGeocodingFeature ( 1<<0 ) Online geocoding is supported.
QGeoServiceProvider::OfflineGeocodingFeature ( 1<<1 ) Offline geocoding is supported.
QGeoServiceProvider::ReverseGeocodingFeature ( 1<<2 ) Reverse geocoding is supported.
QGeoServiceProvider::LocalizedGeocodingFeature ( 1<<3 ) Supports returning geocoding results with localized addresses.
QGeoServiceProvider::AnyGeocodingFeatures ~( 0 ) Matches a geo service provider that provides any geocoding features.

The GeocodingFeatures type is a typedef for QFlags <GeocodingFeature>. It stores an OR combination of GeocodingFeature values.

enum QGeoServiceProvider:: MappingFeature
flags QGeoServiceProvider:: MappingFeatures

Describes the mapping features supported by the geo service provider.

常量 描述
QGeoServiceProvider::NoMappingFeatures 0 No mapping features are supported.
QGeoServiceProvider::OnlineMappingFeature ( 1<<0 ) Online mapping is supported.
QGeoServiceProvider::OfflineMappingFeature ( 1<<1 ) Offline mapping is supported.
QGeoServiceProvider::LocalizedMappingFeature ( 1<<2 ) Supports returning localized map data.
QGeoServiceProvider::AnyMappingFeatures ~( 0 ) Matches a geo service provider that provides any mapping features.

The MappingFeatures type is a typedef for QFlags <MappingFeature>. It stores an OR combination of MappingFeature values.

enum QGeoServiceProvider:: PlacesFeature
flags QGeoServiceProvider:: PlacesFeatures

Describes the places features supported by the geo service provider.

常量 描述
QGeoServiceProvider::NoPlacesFeatures 0 No places features are supported.
QGeoServiceProvider::OnlinePlacesFeature ( 1<<0 ) Online places is supported.
QGeoServiceProvider::OfflinePlacesFeature ( 1<<1 ) Offline places is supported.
QGeoServiceProvider::SavePlaceFeature ( 1<<2 ) Saving places is supported.
QGeoServiceProvider::RemovePlaceFeature ( 1<<3 ) Removing or deleting places is supported.
QGeoServiceProvider::SaveCategoryFeature ( 1<<4 ) Saving categories is supported.
QGeoServiceProvider::RemoveCategoryFeature ( 1<<5 ) Removing or deleting categories is supported.
QGeoServiceProvider::PlaceRecommendationsFeature ( 1<<6 ) Searching for recommended places similar to another place is supported.
QGeoServiceProvider::SearchSuggestionsFeature ( 1<<7 ) Search suggestions is supported.
QGeoServiceProvider::LocalizedPlacesFeature ( 1<<8 ) Supports returning localized place data.
QGeoServiceProvider::NotificationsFeature ( 1<<9 ) Notifications of place and category changes is supported.
QGeoServiceProvider::PlaceMatchingFeature ( 1<<10 ) Supports matching places from two different geo service providers.
QGeoServiceProvider::AnyPlacesFeatures ~( 0 ) Matches a geo service provider that provides any places features.

The PlacesFeatures type is a typedef for QFlags <PlacesFeature>. It stores an OR combination of PlacesFeature values.

enum QGeoServiceProvider:: RoutingFeature
flags QGeoServiceProvider:: RoutingFeatures

Describes the routing features supported by the geo service provider.

常量 描述
QGeoServiceProvider::NoRoutingFeatures 0 No routing features are supported.
QGeoServiceProvider::OnlineRoutingFeature ( 1<<0 ) Online routing is supported.
QGeoServiceProvider::OfflineRoutingFeature ( 1<<1 ) Offline routing is supported.
QGeoServiceProvider::LocalizedRoutingFeature ( 1<<2 ) Supports returning routes with localized addresses and instructions.
QGeoServiceProvider::RouteUpdatesFeature ( 1<<3 ) Updating an existing route based on the current position is supported.
QGeoServiceProvider::AlternativeRoutesFeature ( 1<<4 ) Supports returning alternative routes.
QGeoServiceProvider::ExcludeAreasRoutingFeature ( 1<<5 ) Supports specifying a areas which the returned route must not cross.
QGeoServiceProvider::AnyRoutingFeatures ~( 0 ) Matches a geo service provider that provides any routing features.

The RoutingFeatures type is a typedef for QFlags <RoutingFeature>. It stores an OR combination of RoutingFeature values.

成员函数文档编制

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

构造 QGeoServiceProvider whose backend has the name providerName ,使用提供 参数 .

If multiple plugins have the same providerName , the plugin with the highest reported providerVersion() will be used.

allowExperimental is true then plugins marked as experimental may be used. By default experimental plugins are not considered.

If no plugin matching providerName was able to be loaded then error () 和 errorString () will provide details about why this is the case.

注意: Before the list of 参数 is passed on to the to-be-loaded provider plugin, the list is filtered to avoid the sharing of plugin specific parameters with unrelated provider plugins. Plugin specific parameter keys must be prefixed with the provider name (e.g. here.app_id ).

QGeoServiceProvider:: ~QGeoServiceProvider ()

Destroys the service provider object.

[static] QStringList QGeoServiceProvider:: availableServiceProviders ()

Returns a list of names of the available service providers, for use with the QGeoServiceProvider 构造函数。

Error QGeoServiceProvider:: error () const

Returns an error code describing the error which occurred during the last operation that was performed by this class.

QString QGeoServiceProvider:: errorString () const

Returns a string describing the error which occurred during the last operation that was performed by this class.

GeocodingFeatures QGeoServiceProvider:: geocodingFeatures () const

Returns the geocoding features supported by the geo service provider.

QGeoCodingManager *QGeoServiceProvider:: geocodingManager () const

返回 QGeoCodingManager made available by the service provider.

This function will return 0 if the service provider does not provide any geocoding services.

This function will attempt to construct a QGeoCodingManager instance when it is called for the first time. If the attempt is successful the QGeoCodingManager will be cached, otherwise each call of this function will attempt to construct a QGeoCodingManager instance until the construction is successful.

The QGeoCodingManager is owned by this QGeoServiceProvider and should not be deleted separately. Users should assume that deleting the QGeoServiceProvider renders the pointer returned by this method invalid.

After this function has been called, error () 和 errorString () will report any errors which occurred during the construction of the QGeoCodingManager .

MappingFeatures QGeoServiceProvider:: mappingFeatures () const

Returns the mapping features supported by the geo service provider.

QPlaceManager *QGeoServiceProvider:: placeManager () const

返回 QPlaceManager made available by the service provider.

This function will attempt to construct a QPlaceManager instance when it is called for the first time. If the attempt is successful the QPlaceManager will be cached, otherwise each call of this function will attempt to construct a QPlace instance until the construction is successful.

The QGeoPlaceManager is owned by this QGeoServiceProvider and should not be deleted separately. Users should assume that deleting the QGeoServiceProvider renders the pointer returned by this method invalid.

After this function has been called, error () 和 errorString () will report any errors which occurred during the construction of the QPlaceManager .

PlacesFeatures QGeoServiceProvider:: placesFeatures () const

Returns the places features supported by the geo service provider.

RoutingFeatures QGeoServiceProvider:: routingFeatures () const

Returns the routing features supported by the geo service provider.

QGeoRoutingManager *QGeoServiceProvider:: routingManager () const

返回 QGeoRoutingManager made available by the service provider.

This function will return 0 if the service provider does not provide any geographic routing services.

This function will attempt to construct a QGeoRoutingManager instance when it is called for the first time. If the attempt is successful the QGeoRoutingManager will be cached, otherwise each call of this function will attempt to construct a QGeoRoutingManager instance until the construction is successful.

The QGeoRoutingManager is owned by this QGeoServiceProvider and should not be deleted separately. Users should assume that deleting the QGeoServiceProvider renders the pointer returned by this method invalid.

After this function has been called, error () 和 errorString () will report any errors which occurred during the construction of the QGeoRoutingManager .

void QGeoServiceProvider:: setAllowExperimental ( bool allow )

Sets whether experimental plugins are considered when locating the correct plugin library for this service provider to allow .

Important: this will destroy any existing managers held by this service provider instance. You should be sure not to attempt to use any pointers that you have previously retrieved after calling this method.

void QGeoServiceProvider:: setLocale (const QLocale & locale )

Sets the locale used by this service provider to locale . If the relevant features (see LocalizedMappingFeature etc), this will change the languages, units and other locale-specific attributes of the provider's data.

void QGeoServiceProvider:: setParameters (const QVariantMap & 参数 )

Sets the parameters used to construct individual manager classes for this service provider to 参数 .

Before the list of 参数 is passed on to the to-be-loaded service provider, the list is filtered to avoid the sharing of provider specific parameters with unrelated service providers. Provider specific parameter keys must be prefixed with the provider name (e.g. here.app_id ).

Important: this will destroy any existing managers held by this service provider instance. You should be sure not to attempt to use any pointers that you have previously retrieved after calling this method.