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 (or be removed) without notice depending on the actual availability of a viable openly accessible provider for each type. This also implies that providers serving tiles over HTTPS may be used. This becomes relevant when using the OSM plugin on platforms, such as Android, for which SSL support is not built into Qt by default. 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. Since Qt 5.9.6 the default nominatim endpoint, used for geocoding and places, has also changed to HTTPS-only.

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.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.mapping.cache.directory Absolute path to map tile cache directory used as network disk cache.

The default place for the cache is the QtLocation/osm subdirectory in the location returned by QStandardPaths::writableLocation(), called with QStandardPaths::GenericCacheLocation as a parameter. On systems that have no concept of a shared cache, the application-specific QStandardPaths::CacheLocation is used instead.

osm.mapping.cache.disk.cost_strategy The cost strategy to use to cache map tiles on disk. Valid values are bytesize and unitary. Using bytesize, the related size parameter (osm.mapping.cache.disk.size) will be interpreted as bytes. Using unitary, they will be interpreted as number of tiles. The default value for this parameter is bytesize.
osm.mapping.cache.disk.size Disk cache size for map tiles. The default size of the cache is 50 MiB when bytesize is the cost strategy for this cache, or 1000 tiles, when unitary is the cost strategy.
osm.mapping.cache.memory.cost_strategy The cost strategy to use to cache map tiles in memory. Valid values are bytesize and unitary. Using bytesize, the related size parameter (osm.mapping.cache.memory.size) will be interpreted as bytes. Using unitary, they will be interpreted as number of tiles. The default value for this parameter is bytesize.
osm.mapping.cache.memory.size Memory cache size for map tiles. The default size of the cache is 3 MiB when bytesize is the cost strategy for this cache, or 100 tiles, when unitary is the cost strategy.
osm.mapping.cache.texture.cost_strategy The cost strategy to use to cache decompressed map tiles in memory. Valid values are bytesize and unitary. Using bytesize, the related size parameter (osm.mapping.cache.texture.size) will be interpreted as bytes. Using unitary, they will be interpreted as number of tiles. The default value for this parameter is bytesize.
osm.mapping.cache.texture.size Texture cache size for map tiles. The default size of the cache is 6 MiB when bytesize is the cost strategy for this cache, or 30 tiles, when unitary is the cost strategy. Note that the texture cache has a hard minimum size which depends on the size of the map viewport (it must contain enough data to display the tiles currently visible on the display). This value is the amount of cache to be used in addition to the bare minimum.
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.custom.host Url string of a custom tile server. This parameter should be set to a valid server url offering the correct osm API. To use this server, the Map::activeMapType parameter of the Map should be set to the supported map type whose type is MapType.CustomMap. This map type is only be available if this plugin parameter is set, in which case it is always Map::supportedMapTypes[supportedMapTypes.length - 1].

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.highdpi_tiles Whether or not to request high dpi tiles. Valid values are true and false. The default value is false. Please note that not all map types are available in high dpi. Setting this parameter to true might even have no effect if no map type is available in high dpi at the moment. Provider information files for high dpi tiles are named street-hires, satellite-hires, cycle-hires, transit-hires, night-transit-hires, terrain-hires and hiking-hires. These are fetched from the same location used for the low dpi counterparts.
osm.mapping.offline.directory Absolute path to a directory containing map tiles used as an offline storage. If specified, it will work together with the network disk cache, but tiles won't get automatically inserted, removed or updated. The format of the tiles is the same used by the network disk cache. There is no default value, and if this property is not set, no directory will be indexed and only the network disk cache will be used to reduce network usage or to act as an offline storage for the currently cached tiles.
osm.mapping.prefetching_style This parameter allows to provide a hint how tile prefetching is to be performed by the engine. The default value, TwoNeighbourLayers, makes the engine prefetch tiles for the layer above and the one below the current tile layer, providing ready tiles when zooming in or out from the current zoom level. OneNeighbourLayer only prefetches the one layer closest to the current zoom level. Finally, NoPrefetching allows to disable the prefetching, so only tiles that are visible will be fetched. Note that, depending on the active map type, this hint might be ignored.
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.places.debug_query Set this parameter to true to have an extended attribute in each result named "requestUrl", and containing the url used for the query. Default is false.
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.

osm.places.page_size The amount of results in a page. Note that this value might be clamped server side. The typical maximum in standard nominatim instances is 50.
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.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.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)

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.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.12/location-plugin-osm.html