0

By following a part of this example

display multiple routes on a map using RouteMap QML Qt

I'm trying to show a route inside a MapView in a QML view of my QT application, by using the following code; but the route don't appear. No errors are appearing in the output console. Did I do something wrong?

Map {
        anchors.fill: parent
        plugin: mapboxglPlugin
        center: QtPositioning.coordinate(60.170448, 24.942046) // Oslo
        zoomLevel: 16
        id: mapMain
        copyrightsVisible: false

        
        RouteModel {
            id: rm
            plugin: mapboxglPlugin
            query: RouteQuery {id: routeQuery }
            Component.onCompleted: {
                routeQuery.addWaypoint(QtPositioning.coordinate(60.170448, 24.942046));
                routeQuery.addWaypoint(QtPositioning.coordinate(62.170448, 23.942046));
                update();
            }
        }

        MapItemView {
            model: rm
            delegate: Component{
                MapRoute {
                    route: routeData
                    line.color: "green"
                    line.width: 5
                    smooth: true
                }
            }
        }
}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Archimede
  • 699
  • 3
  • 15
  • 28
  • 1
    I've checked the code with minimal changes and that works as expected. Please check the following: you have `mapboxglPlugin` item and that works, i.e. you see the map at least. you have all the imports, at least `import QtLocation 5.15` and `import QtPositioning 5.2`. Try to change the plugin to maybe "osm". Try to run the code from QtCreator in Debug mode and check the Application output tab. – folibis Jul 07 '21 at 06:53
  • @folibis It works by adding also in the Cmake file the component you mentioned, thank you very much! – Archimede Jul 08 '21 at 08:55

0 Answers0