Map Plugin shows no service providers

469 views Asked by At

I'm trying to render an empty Map in QML 5.7, in order to draw geolocated polylines. However, no plugins are available to supply the map data:

Map {
    anchors.fill:parent
    plugin: Plugin {
        name: "osm"
        Component.onCompleted: console.log('a',availableServiceProviders.length)
    }

    MapPolyline {
        line.color: "#299FE7"; line.width: 3
        path: parent.points
    }

    Timer {
        running:true; interval:1000
        onTriggered: console.log('b',parent.supportedMapTypes.length)
    }
}

The above outputs:

qml: a  0
qml: b  0

Why don't I have any plugins available, and how can I get one to work?

1

There are 1 answers

0
BaCaRoZzo On BEST ANSWER

You don't have a default provider because Qt does not enforce the usage of a specific one. Even more now that all of the available ones require a registration (and the acceptance of an agreement/ToS) to use their services.

The list of available plugins can be found here. Following the links you can read about the specific setup for the usage of each one.

Adding a provider in QML is just a matter of declaring a Plugin type, something along the line of that:

Plugin {
    name: <provider_name> // { "here" | "mapbox" | "osm" }
    PluginParameter { name: <param_name>; value: <param_value> }
    // other parameters
}

The very same task can be carried out in a C++/non-QML project via QGeoServiceProvider class.

Mind that the access to MapQuest changed few months ago, breaking the Open Street Map plugin. You now need credentials to access their service, e.g. read this comment. The relevant patch has been pushed and merged, as stated in the bug report page of last linked comment, and will be available in Qt 5.6.2 (and Qt 5.7.1) patch release.