TransWikia.com

Qt Offline OSM Map freezes

Geographic Information Systems Asked on November 23, 2021

I am developing an application that needs to show map tiles without internet. My initial step is to show map tiles, that part is done. Next step is to show tiles without internet. I tried to get tile images from my local directory but program stuck on the beginning and reading tiles from the given directory. What should I do? Should I serve my tiles on a local server? Or what is the best way to work at offline mode.

import QtQuick.Controls 2.4
import QtLocation 5.8
import QtPositioning 5.2
import QtGraphicalEffects 1.0

Item {
    height: 1080
    width: 1920
    Rectangle {
        anchors.fill: parent
        Plugin {
            id: plugin
            name: "osm"
            PluginParameter{
                name: "osm.mapping.offline.directory"
                value: "MAP_TILE_PATH"
            }
        }

        Map {
            id: maps
            anchors.fill: parent
            plugin: plugin
            gesture.enabled: true
            gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture
                                      | MapGestureArea.FlickGesture
            gesture.flickDeceleration: 3000
            focus: true
            zoomLevel: 10
            center: QtPositioning.coordinate(41,30)
            minimumZoomLevel: 1
            copyrightsVisible: false
            onCenterChanged: {
                console.log(maps.center)
            }
        }
    }
}

2 Answers

Another solution is that (using currently) serve your tiles in local http server and pass the url of your server to the osm.mapping.providersrepository.address parameter.

PluginParameter{
    name:"osm.mapping.providersrepository.address"
    value: "http://127.0.0.1:8080/"
}

Answered by Berkant Ay on November 23, 2021

In qt source code you may change the wildcard symbol to the file formats of your tiles.

https://code.qt.io/cgit/qt/qtlocation.git/tree/src/plugins/geoservices/osm/qgeofiletilecacheosm.cpp?h=dev#n158
const QString fileName = tileSpecToFilename(spec, QStringLiteral("*"), providerId);

then you need to recompile Qt.

Answered by Berkant Ay on November 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP