Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Location show a Route
QtWS25 Last Chance

QML Location show a Route

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 2 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

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

      and

      @
      routeData.travelTime
      @

      both is 0.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dicksonleong
        wrote on last edited by
        #3

        Try remove the PluginParameters and see if it works?

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          I tried that. It does not work, too.

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            Really nobody can help me?

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

            Thank you.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amccarthy
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  amccarthy
                  wrote on last edited by
                  #8

                  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()
                      }
                  }
                  

                  }
                  @

                  1 Reply Last reply
                  0
                  • ? This user is from outside of this forum
                    ? This user is from outside of this forum
                    Guest
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved