I've setup a local tile server to use with my application but when I create my QML Map object and specify the plugin to use a custom host, the application does not use the local tiles. Cycling through supportedMapTypes
and setting the activeMapType
property on the map object will display some tiles, but they appear to be some set of default tiles and not the tiles from my local tile server.
Map
{
id: map
objectName: "basemap"
anchors.fill: parent
plugin: Plugin
{
name: "osm"
PluginParameter
{
name: "osm.mapping.custom.host"
value: "http://localhost:8080/data/openmaptiles_satellite_lowres/"
}
}
zoomLevel: 1
activeMapType: // varies depending on selection from another object in application
center: QtPositioning.coordinate(0, 0)
}
I know the tile server is functioning properly as I can reach it in the browser by navigating to localhost:8080
and I can access arbitrary tiles using http://localhost:8080/data/openmaptiles_satellite_lowres/{z}/{y}/{x}.jpg
UPDATE
I'm trying to override the default provider repository files as suggested below by TomasL but the application doesn't seem to be using the plugin parameters specified.
Map component in Mapper.qml
Map {
id: basemap
objectName: "basemap"
anchors.fill: parent
plugin: ProvidersPlugin {}
activeMapType: supportedMapTypes[1] // To use the satellite file in providers repository
center: QtPositioning.coordinate(0, 0)
zoomLevel: 2
minimumZoomLevel: 0
maximumZoomLevel: 5
}
ProvidersPlugin.qml
import QtLocation 5.5
import QtPositioning 5.5
Plugin {
id: mapPlugin
name: "osm"
PluginParameter {
name: "osm.mapping.providersrepository.address"
value: Qt.resolvedUrl('./providers')
}
}
./providers/satellite
{
"Enabled" : true,
"UrlTemplate" : "http://localhost:8080/data/openmaptiles_satellite_lowres/%z/%x/%y.jpg",
"ImageFormat" : "jpg",
"QImageFormat" : "Indexed8",
"MapCopyRight" : "Test",
"DataCopyRight" : "Hello World",
"MinimumZoomLevel" : 0,
"MaximumZoomLevel" : 5,
}
With the code above, my application still tries to reach out to the default server otile1.mqcdn.com
The problem is that the media you are using provides jpg images but the Qt OSM plugin only supports png formats. One solution is to clone the Qt Location module, modify the source code so that the image format can be set, compiled and installed.
To simplify that task I have created a patch for Qt 5.15.1:
tile_image_format.patch
The steps outlined above can be summarized as:
On the other hand you must point activeMapType in MapType.CustomMap: