Qt 5.6 | Qt Location | Qt Location Open Street Map Plugin

Qt 5.6.3 Reference Documentation

# Qt Location Open Street Map Plugin

## Overview

This geo services plugin allows applications to access Open Street Map location based services using the Qt Location API.

Data, imagery and map information provided by OpenMapSurfer, ThunderForest, OpenStreetMap and contributors. The data is available under the Open Database License.

The Open Street Map geo services plugin can be loaded by using the plugin key "osm".

Note: Since Qt 5.6.2, the available map types offered by this plugin may change without notice depending on the actual availability of each provider. To prevent these changes, either a different geo service plugin should be used, or the plugin parameter osm.mapping.providersrepository.address should be set to a user-specified repository, in order to take full control over (and accept responsibility for) selecting the provider that is used for each map type.

## Parameters

### Optional parameters

The following table lists optional parameters that can be passed to the Open Street Map plugin.

Note: Since Qt 5.5 all parameters below must be prefixed with `osm`. Previous versions did not require a prefix.

Parameter | Description
--- | ---
osm.useragent | User agent string set when making network requests. This parameter should be set to a value that uniquely identifies the application. Note that providers might block applications not setting this parameter, leaving it to the stock plugin user agent (e.g., Nominatim for geocoding)

osm.mapping.custom.host

Url string set when making network requests to the tile server. This parameter should be set to a valid server url with the correct osm api and the Map::activeMapType to the corresponding MapType.CustomMap. The CustomMap will only be available if this parameter is set.

Note: Setting the mapping.custom.host parameter to a new server renders the map tile cache useless for the old custommap style.

osm.mapping.custom.mapcopyright | Custom map copryright string is used when setting the Map::activeMapType to MapType.CustomMap via urlprefix parameter. This copyright will only be used when using the CustomMap from above. If empty no map copyright will be displayed for the custom map.
osm.mapping.custom.datacopyright | Custom data copryright string is used when setting the Map::activeMapType to MapType.CustomMap via urlprefix parameter. This copyright will only be used when using the CustomMap from above. If empty no data copyright will be displayed for the custom map.

osm.mapping.providersrepository.address

The OpenStreetMap plugin retrieves the provider's information from a remote repository. This is done to prevent using hardcoded servers by default, which may become unavailable. By default this information is fetched from maps-redirect.qt.io. Setting this parameter changes the provider repository address to a user-specified one, which must contain the files `street`, `satellite`, `cycle`, `transit`, `night-transit`, `terrain` and `hiking`, each of which must contain valid provider information.

osm.mapping.providersrepository.disabled

By default, the OpenStreetMap plugin retrieves the provider's information from a remote repository to avoid a loss of service due to unavailability of hardcoded services. The plugin, however, still contains fallback hardcoded provider data, in case the provider repository becomes unreachable. Setting this parameter to true makes the plugin use the hardcoded urls only and therefore prevents the plugin from fetching provider data from the remote repository.

osm.routing.host | Url string set when making network requests to the routing server. This parameter should be set to a valid server url with the correct osrm API. If not specified the default url will be used. Note: The API documentation and sources are available at Project OSRM.
osm.routing.apiversion | String defining the api version of the (custom) OSRM server. Valid values are v4 and v5. The default is v5. This parameter should be set only if `osm.routing.host` is set, and is an OSRM v4 server.
osm.geocoding.host | Url string set when making network requests to the geocoding server. This parameter should be set to a valid server url with the correct osm API. If not specified the default url will be used. Note: The API documentation is available at Project OSM Nominatim.
osm.places.host | Url string set when making network requests to the places server. This parameter should be set to a valid server url with the correct osm API. If not specified the default url will be used. Note: The API documentation is available at Project OSM Nominatim.

## Parameter Usage Example

The following example shows how to create an OSM plugin instance with parameters supplied for an useragent, and if necessary, a custom server url plus the corresponding copyright information for the tile provider. Additionally, it is possible to choose another routing server than the public osrm one.

### QML

      Plugin {
          name: "osm"
          PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
          PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
          PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
          PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
          PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
      }

## Other Plugin-specific Information

### Tile cache

The tiles are cached in a `QtLocation/osm` directory in QStandardPaths::writableLocation (QStandardPaths::GenericCacheLocation). On systems that have no concept of a shared cache, the application-specific QStandardPaths::CacheLocation is used instead.