- Qt 5.5
- Qt Location
- C++ Classes
- QGeoServiceProvider
- Qt 5.5.1 Reference Documentation

# QGeoServiceProvider Class

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

Header: | #include <QGeoServiceProvider>
qmake: | QT += location
Since: | Qt 5.5
Inherits: |

- List of all members, including inherited members

## Public Types

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

## Public Functions

| QGeoServiceProvider(const QString & providerName, const QVariantMap & parameters = 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 & parameters)

## Static Public Members

QStringList | availableServiceProviders()

## Detailed Description

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.

Subclasses of 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:

- "mapbox" -> Mapbox service
- "here" -> HERE Services
- "osm" -> OpenStreetMap Services

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.

## Member Type Documentation

### enum QGeoServiceProvider::Error

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

Constant | Value | Description
--- | --- | ---
`QGeoServiceProvider::NoError` | `0` | No error has occurred.
`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.

Constant | Value | Description
--- | --- | ---
`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.

Constant | Value | Description
--- | --- | ---
`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.

Constant | Value | Description
--- | --- | ---
`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.

Constant | Value | Description
--- | --- | ---
`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.

## Member Function Documentation

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

Constructs a QGeoServiceProvider whose backend has the name providerName, using the provided parameters.

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

If 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() and errorString() will provide details about why this is the case.

Note: Before the list of parameters 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 constructors.

### 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

Returns the 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() and 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

Returns the 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() and 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

Returns the 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() and 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 & parameters)

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

Before the list of parameters 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.