Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT QML QtLocation map plugin

Tags:

qt

qml

qtlocation

I have my own local Z/X/Y map tile server and want to use it as a map background in a QML application. Looking at sample code it appears that this is done by:-

 Plugin {
    id: osmPlugin
    name: "osm"
 }

So I need to write my own plugin. But the documentation seems sparse and I cannot find the source code for the osm version or installation instructions.

Is this relatively easy to do, or can it be done without writing a new plugin?

like image 359
CF-GISRAW Avatar asked Feb 22 '17 21:02

CF-GISRAW


1 Answers

You can set the osm.mapping.host like this:

    Plugin {
        id: osmPlugin
        name: "osm"


        PluginParameter { name: "osm.mapping.host"; value: "https://tile.openstreetmap.org/" }
        PluginParameter { name: "osm.geocoding.host"; value: "https://nominatim.openstreetmap.org" }
        PluginParameter { name: "osm.routing.host"; value: "https://router.project-osrm.org/viaroute" }
        PluginParameter { name: "osm.places.host"; value: "https://nominatim.openstreetmap.org/search" }
        PluginParameter { name: "osm.mapping.copyright"; value: "" }
        PluginParameter { name: "osm.mapping.highdpi_tiles"; value: true }
    }

But don't forget to set Custom Map type using the following code:

    Map {
        id: map
        height: parent.width
        width: parent.width
        plugin: osmPlugin

        Component.onCompleted: {
            for( var i_type in supportedMapTypes ) {
                if( supportedMapTypes[i_type].name.localeCompare( "Custom URL Map" ) === 0 ) {
                    activeMapType = supportedMapTypes[i_type]
                }
            }
        }
    }
like image 175
Mohamed Alkaduhimi Avatar answered Sep 23 '22 17:09

Mohamed Alkaduhimi