1

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]
}

}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • could you show me how you put the map? means your folder that contains the map. you should use tile maps. (TMS) – Parisa.H.R Aug 07 '21 at 17:17
  • @Parisa.H.R there's no folder. The map is inside a docker volume. The docker runs a server and bring me the tiles that I request. – Mario De Santis Aug 07 '21 at 17:52
  • docker how get map? from where? one time I use apache2 for do such things . its important that your map be TMS . – Parisa.H.R Aug 07 '21 at 17:53
  • so, there is a folder binding with docker. the current location is in the path: /home/zambia-latest.osm.pbf – Mario De Santis Aug 07 '21 at 17:56
  • no, it should be folders that its name has just number (1,2,3,..) this number shows zoom level of map and in each folder there is png or jpg Tile map. like [this question folder picture](https://stackoverflow.com/questions/41620176/how-to-render-custom-map-tiles-created-with-gdal2tiles-in-leaflet-for-r) – Parisa.H.R Aug 07 '21 at 18:00
  • @Parisa.H.R. are you suggesting to create a type of db from zero? will not be more efficiency to use the already *osm.pbf data base and generate an tile png on demand as the project switch2OSM does? – Mario De Santis Aug 07 '21 at 18:04
  • no, not DB, you can get a map and cache it in one server and then connect to that. I don't know may be your docker has a problem , I didn't use docker. – Parisa.H.R Aug 07 '21 at 18:06
  • @Parisa.H.R. I appreciate you, I'll try to figure out about what did you said and how can I work on it. – Mario De Santis Aug 07 '21 at 18:10
  • @Parisa.H.R The problem cannot be docker since the OP indicates that if it visualizes the images in the search engine. The docker just converts the .pbf into images (.png) using switch2osm and displays them via a server. The docker allows the user not to worry about implementing the project (installing dependencies, compiling switch2osm, setting up the server, etc). So if the server works then the client is the one that is misconfigured, my answer uses the correct parameters and it works. – eyllanesc Aug 07 '21 at 23:57
  • @eyllanesc , thanks. I didn't know this. – Parisa.H.R Aug 08 '21 at 00:40

1 Answers1

1

You have 2 errors:

  • The host is wrong.
  • The coordinate is not to Zambia but to Poland
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

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • It' seems to work. But I still getting an error when my application try to communicate with the server: {GeoTileRequestManager: Failed to fetch tile (2370,2224,12) 5 times, giving up. Last error message was: 'Error transferring http://localhost/tile/12/2370/2224.png - server replied: Not Found'}. @eyllanesc, Have you got this issue? – Mario De Santis Aug 08 '21 at 14:37
  • @MarioDeSantis The coordinates seem like they are not part of the map so you get that error. In your browser open the link and check what you get. – eyllanesc Aug 08 '21 at 15:24