Qt / Qml: how to enable tiles for offline use?

I need to include offline tiles (slippy map) in the Qt / Qml mobile application, which mainly works on Android and iOS.

The only well-documented and working solution I found was the Esri Arcgis Runtime commercial work for Qt. However, to create tile packages, you need to use the Arcgis stack, whether it be the desktop or the server (please correct me if I am wrong).

https://developers.arcgis.com/qt/

I am looking for an open source alternative and easy to use.

QtLocation has just improved in Qt 5.5, but there seems to be no solution for standalone tile packages:

http://doc-snapshots.qt.io/qt5-5.5/qtlocation-index.html

+4
source share
3 answers

Using offline maptiles is now possible through the ArcGIS Runtime time library, starting with version 10.2.6:

https://developers.arcgis.com/qt/qml/api-reference/class_tiled_map_service_layer.html

0
source

I know this answer was late, but I had the same problem with client standalone cards in Linux

You need to create a directory structure for your map tile. Since I used openstreetmaps, I copied the directory structure that they use, i.e. Root / zoom_level / area_level_1 / area_level_2 / tile.png

eg.

~ / osmTiles / 12/3820 / 2078.png

(https://marble.kde.org/install.php?), ( ), osm .png

npm node.js http- http- http//localhost: port ( : fooobar.com/questions/6569/...)

.:

http-server ~/osmTiles -p 8080

, osmTiles http//127.0.0.1: 8080

, QML

Plugin {
  id: osmPlugin
  name: "osm"
  PluginParameter { name: "osm.useragent";         value: "My Company Name" }
  PluginParameter { name: "osm.mapping.host";      value: "http://127.0.0.1:8080/" }
  PluginParameter { name: "osm.mapping.copyright"; value: "MyCompany" }
}

QML, . , , . , supportedMapTypes [7] . , , ,

Map{
  plugin: osmPlugin
  activeMapType: supportedMapTypes[7]
}
+3

@Marco Piccolino, , , , QtLocation, HTTP-:

  • png- : ".../tiles/1.0.0/sat/{z}/{x}/{y}.png", cf this

  • http- ( : sudo python -m SimpleHTTPServer 80)

  • You will need to edit the hosts file to map the following domain to your server IP address (most likely 127.0.0.1): otile1.mqcdn.com . This trick is pretty dirty, but since this url is hardcoded in the QtLocation OSM plugin, we have virtually no choice with the currently available QML API.

  • Finally, the simplest part, in QML code, you should have something like this:

Plugin {
    id: mapProvider
    name: "osm"
}

Map {
    anchors.fill: parent
    plugin: mapProvider
    gesture.enabled: true
    activeMapType: supportedMapTypes[1]
}

+2
source

All Articles