Use an offline interactive map in QML

Grégoire Borel picture Grégoire Borel · Apr 15, 2016 · Viewed 7k times · Source

I'd like to inject a chunk of map that I got from OpenStreetMap under the form of an osm file.

From what I've read in the documentation, the Open Street Map Plugin doesn't seem to have any parameter taking a source file as a map. It only works with a server. Problem is I won't have an Internet connection when running my application. I need to use a map internally.

Ditto for Mapbox and HERE plugins.

Is there any other way to do this?

Here is the boilerplate to create a Map:

Plugin {
    id: somePlugin
    // code here to choose the plugin as necessary
}

Map {
    id: map

    plugin: somePlugin

    center {
        latitude: -27
        longitude: 153
    }
    zoomLevel: map.minimumZoomLevel

    gesture.enabled: true
}

Answer

Marco Piccolino picture Marco Piccolino · Apr 16, 2016

Update April 2017: QtLocation now supports offline OSM tiles. See http://doc.qt.io/qt-5/location-plugin-osm.html

As you note, QtLocation currently does not give you the offline option. Also, for basemaps it currently only supports image tiles (not the XML vector OSM data you are talking about).

You have a few alternatives:

In QML: you can use the ArcGIS Runtime SDK for Qt. Starting from version 10.26 it supports adding custom map layers with offline tiles. You will need to get PNG/JPG tiles of your OSM data first. Here is an example layer that supports OSM slippymap tiles.

In C++: you will find a few options to display vector data that might require or not conversion from the OSM format and more work on your side:

Also, don't forget to vote for the issues mentioned above in Qt Bugtracker!