qtqmlopenstreetmapofflineqtlocation

QML Custom Tile server


I'm trying to plot an offline map using a custom server that my machine is hosting. I've followed the steps of this project for docker. It works when I use my browser (http://localhost:8080/). But when I try to access QML using the code below I just get a Static image GPS output

 GPS output .

What am I doing wrong? I should see Zambia with a good resolution as I see in the Browser.

QML CODE

import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.VirtualKeyboard 2.4
import QtLocation 5.11
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
title: qsTr("GPS")
Plugin{
    id: plugin_osm
       name: "osm"
       PluginParameter {
             name: "osm.mapping.custom.host"
             value: "http://localhost:8080"
          }

          /*disable retrieval of the providers information from the remote repository.
          If this parameter is not set to true (as shown here), then while offline,
          network errors will be generated at run time*/
          PluginParameter {
             name: "osm.mapping.providersrepository.disabled"
             value: true
          }

       }

Map {
    id: map
    anchors.fill: parent
    plugin: plugin_osm

    zoomLevel: 12
    minimumZoomLevel: 5
    maximumZoomLevel: 17
    center: QtPositioning.coordinate(54.2,16.2)
    activeMapType: supportedMapTypes[supportedMapTypes.length - 1]
}

}

Solution

  • You have 2 errors:

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import QtLocation 5.15
    import QtPositioning 5.15
    
    
    ApplicationWindow {
        id: window
    
        width: 640
        height: 480
        visible: true
        title: qsTr("GPS")
    
        Plugin {
            id: plugin_osm
    
            name: "osm"
    
            PluginParameter {
                name: "osm.mapping.custom.host"
                value: "http://localhost/tile/"
            }
            /*disable retrieval of the providers information from the remote repository.
              If this parameter is not set to true (as shown here), then while offline,
              network errors will be generated at run time*/
    
            PluginParameter {
                name: "osm.mapping.providersrepository.disabled"
                value: true
            }
    
        }
    
        Map {
            id: map
    
            anchors.fill: parent
            plugin: plugin_osm
            zoomLevel: 12
            minimumZoomLevel: 5
            maximumZoomLevel: 17
            center: QtPositioning.coordinate(-15.4067, 28.2871)
            activeMapType: supportedMapTypes[supportedMapTypes.length - 1]
        }
    
    }
    

    Output:

    enter image description here