Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use an offline interactive map in QML

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
}
like image 838
Grégoire Borel Avatar asked Apr 15 '16 12:04

Grégoire Borel


2 Answers

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:

  • http://wiki.openstreetmap.org/wiki/Libosmscout
  • https://www.mapbox.com/blog/qmapboxgl/
  • QGis is made in Qt, as are many other opensource geographic projects, so they might be helpful

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

like image 142
Marco Piccolino Avatar answered Nov 19 '22 13:11

Marco Piccolino


You can generate or download tiles for offline usage. For generating tiles take a look at TileMill or Maperitive. Downloading tiles can be achieved via Marble and various other tools, but please respect the tile server's usage policy! Downloading high zoom tiles causes high load on the tile server because these tiles are usually not cached and need to be rendered on the fly.

like image 4
scai Avatar answered Nov 19 '22 11:11

scai