Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

OSM offline : mbtile server not working



  • I have downloaded the mbtile map file from here.
    I have used the following the in the qml

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import QtLocation 5.8
    Window {
        id: win
        visible: true
        width: 640
        height: 480
        title: qsTr("test map view")
        Map {
            id:map
            anchors.fill: parent
            activeMapType: map.supportedMapTypes[supportedMapTypes.length - 1]
            zoomLevel: 1
            center {
                    latitude: 13.0827
                    longitude: 80.2707
            }
            plugin: Plugin {
                    name: "osm"
                          PluginParameter { name: "osm.useragent";value: "MyOSM" }
                          PluginParameter { name: "osm.mapping.custom.host";value: "http://127.0.0.1:8080/"}
                          PluginParameter { name: "osm.mapping.copyright"; value: "OSM" }
                          PluginParameter { name: "osm.mapping.cache.directory"; value: "/home/karthi/Qt/qtilestream-master/cache_folder" }
                          PluginParameter { name: "osm.mapping.providersrepository.disabled";value: true}
    
            }
    
         }
    }
    
    

    I am running tile server on the local host and port 8080. But i am getting a blank screen with no map loaded. Am i missing something ?



  • Hi @name_qt,

    I had some problems with displaying maps (don't remember now what exactly was the issue about) and adding this code helped:

    Map {
            [...]
            Component.onCompleted: {
                for( var i_type in supportedMapTypes ) {
                    if( supportedMapTypes[i_type].name.localeCompare( "Custom URL Map" ) === 0 ) {
                        activeMapType = supportedMapTypes[i_type]
                    }
                }
            }
    }
    

    I think I had to add it when I was playing with different set-up of osm.mapping.host and osm.mapping.custom.host fields.



  • Thanks for your response @osmial.
    I believe the supported maptype id is 7 for custom maps. 0-6 will give the in build maptypes. That is why i gave like this

    map.supportedMapTypes[supportedMapTypes.length - 1]
    

    I did also check with your code and i had the same result. I checked with

    console.log(i_type);
    

    and it is giving 7.

    The application is running, but the map is blank.


Log in to reply