Search code examples
qtopenstreetmapofflineqtlocation

Using offline data with QtLocation plugin


I have 500mb of offline data I would like to use with the OSM QtLocation plugin. I used the sample source code from this blog https://www.qt.io/blog/2017/05/24/qtlocation-using-offline-map-tiles-openstreetmap-plugin. The data in the sample app is embedded in the resource file, I would like to have it in a separate folder on the disk. For a start I would like to get the sample app working with the sample data located in a folder on disk and not as compiled in resource files. When executing the app it still downloads the data from the online server. I have read lots of articles online but none of the solutions are working. I am using Qt 5.15.2, Windows 10 with MSVC compiler.

This is how my code looks like.

import QtQuick 2.7
import QtQuick.Window 2.2
import QtLocation 5.8

Window {
    id: win
    objectName: "window"
    visible: true
    width: 512
    height: 512

    Map {
        id: map
        anchors.fill: parent
        activeMapType: map.supportedMapTypes[1]
        zoomLevel: 1
        plugin: Plugin {
            id: osmPLugin
            name: 'osm';
            PluginParameter { name: 'osm.mapping.offline.directory'; value: 'file:///c:/offline_tiles/' }
        }
    }
}

Solution

  • You have to use the path, not the uri:

    PluginParameter { name: 'osm.mapping.offline.directory'; value: 'c:/offline_tiles/' }