QML Location show a Route



  • Hi, I want to try out some functions of Qt Location 5.0.
    I'm only using QML Quick 2.0.

    So I already activated and added the Plugin, "nokia" with the token and the app_id.
    I also added the Proxy, so that so Map can be loaded.

    Showing the Map and navigate to some Places with coordinates already works.
    Map Circles and MapQuickItem works, too.

    Now my problem, I added:

    @
    Plugin {
    id: myplugin
    name : "nokia"
    parameters: [
    PluginParameter { name: "app_id"; value: "xxx" },
    PluginParameter { name: "token"; value: "xxx" }
    ]
    }
    @

    @
    Map{
    plugin: myplugin

    Route{
    id: routeData
    }

    RouteQuery {
    id: aQuery
    }

    RouteModel {
    id: routeModel
    plugin: myplugin
    query: aQuery
    autoUpdate: false
    }

    MapItemView {
    model: routeModel
    delegate: routeDelegate
    }

    Component {
    id: routeDelegate

    MapRoute {
      route: routeData
      line.color: "blue"
      line.width: 5
      smooth: true
    }
    

    }
    }
    @

    Now, on klick I change in JavaScript

    @
    aQuery.addWaypoint(startcoordinates)
    aQuery.addWaypoint(endcoordinates)
    aQuery.travelModes = RouteQuery.CarTravel
    routeModel.update()@

    There is no error shown, but it dows not work, too.

    Can anyone help me?

    Thank you.



  • When I read and display the Data of routeData, then there is no error, too.
    But
    @
    routeData.distance
    @

    and

    @
    routeData.travelTime
    @

    both is 0.



  • Try remove the PluginParameters and see if it works?



  • I tried that. It does not work, too.



  • Really nobody can help me?

    It is very important, because I need it for my Master Thesis.

    Thank you.



  • The problem is that you are defining a Route object with id routeData. The route delegate will get the Route object describing the route directly from the RouteModel, as a named data role.

    Remove the Route object and it should work.

    You will need to keep the PluginParameters, otherwise the Nokia services will reject your requests.



  • First of all, thank you very much for your answer.

    I tried it without:
    @
    Route{
    id: routeData
    }
    @

    Then when I use
    @
    MapRoute {
    route: routeData
    line.color: "blue"
    line.width: 5
    smooth: true
    }
    @

    for painting the Route I get an error, routeData not found.

    when I replace in MapRoute
    @routeData@

    with
    @routeModel@

    or
    @routeDelegate@

    then it does not work, too.

    Is there a second mistake from me?

    Thank you for your help.



  • Can you verify that the mapviewer example works with your app_id and token. You can test routing in the mapviewer example as well.

    I used the following code and it works as expected. Clicking on the map will cause a route to be calculated and displayed near the center of the display. What coordinates are you using for the start and end of the route?

    @
    import QtQuick 2.0
    import QtLocation 5.0

    Item {
    Plugin {
    id: myplugin
    name : "nokia"
    parameters: [
    PluginParameter { name: "app_id"; value: "xxx" },
    PluginParameter { name: "token"; value: "xxx" }
    ]
    }

    Map {
        plugin: myplugin
    
        anchors.fill: parent
    
        RouteQuery {
            id: aQuery
        }
    
        RouteModel {
            id: routeModel
            plugin: myplugin
            query: aQuery
            autoUpdate: false
        }
    
        MapItemView {
            model: routeModel
            delegate: routeDelegate
        }
    
        Component {
            id: routeDelegate
    
            MapRoute {
                route: routeData
                line.color: "blue"
                line.width: 5
                smooth: true
            }
        }
    }
    
    Coordinate {
        id: start
        latitude: -27.3
        longitude: 153.1
    }
    
    Coordinate {
        id: end
        latitude: -27.4
        longitude: 153.1
    }
    
    MouseArea {
        anchors.fill: parent
        onClicked: {
            aQuery.addWaypoint(start)
            aQuery.addWaypoint(end)
            aQuery.travelModes = RouteQuery.CarTravel
            routeModel.update()
        }
    }
    

    }
    @



  • Hi. Thank You for Your answer.
    I tried the mapviewer example but I can not get a route there, too.

    The Coordinates are okay, I tested them at an Html Example from Nokia Developer Site.

    So the problem muss be the connection to the Server or the Plugin.

    My Plugin is activated at Nokia and should work.

    @
    Plugin {
    id: myplugin
    name : "nokia"
    parameters: [
    PluginParameter { name: "app_id"; value: "xxx" },
    PluginParameter { name: "token"; value: "xxx" }
    ]
    }
    @

    Internet connection works, too. I connect over a Proxy.

    @
    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::Socks5Proxy);
    proxy.setType(QNetworkProxy::HttpProxy);
    proxy.setHostName("XXX");
    proxy.setPort(8080);
    proxy.setUser("XXX");
    proxy.setPassword("XXX");
    QNetworkProxy::setApplicationProxy(proxy);
    @

    The Map loads dynamical the next images if I pan or change coordinates.

    The only thing that not works is to display the Route.

    I use the Qt 5 Alpha release, could this be the reason or can you find a mistake in the proxy connection?

    Thank you very much for your help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.