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. GeocodeModel doesn't work and problem with RouteModel

GeocodeModel doesn't work and problem with RouteModel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 546 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    DragonCoder
    wrote on last edited by DragonCoder
    #1

    Hi,
    i have a little problem with my Code.

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import QtQuick.Window 2.0
    import QtLocation 5.6
    import QtPositioning 5.6
    
    
    
    ApplicationWindow {
    
        id: app_window
        visible: true
        width: 1024
        height: 800
        title: qsTr("Navigation")
    
    
            PositionSource {
                active: true
                onPositionChanged: {
                    map_id.center = position.coordinate;
                }
            }
    
    
            Rectangle {
                id: mapRectangleID
                width: 1024
                height: 800
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
    
                Map {
                    id: map_id
                    anchors.fill: parent
                    plugin: Plugin { name: "osm" }
                    center: QtPositioning.coordinate(51.320729390711975,12.280097007751465)
                    zoomLevel: 15
    
                    MapQuickItem {
                        //coordinate: QtPositioning.coordinate(59.91, 10.75)
                        sourceItem: Image {
                            id: endPointImage
                            source: "assets/marker.png"
                            width: 40.1
                            height: 34.3
                        } //size and position of maker
                        anchorPoint.x: endPointImage.width / 2
                        anchorPoint.y: endPointImage.height
                    } //marker
    
                 RouteModel {
                        id: routeBetweenPoints
                        plugin: Plugin { name: "osm" }
                        query: RouteQuery {id: routeQuery }
                        Component.onCompleted: {
                            routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
                            routeQuery.addWaypoint(QtPositioning.coordinate(51.3117764,12.280909000000065 ));
                            //routeQuery.addWaypoint(endPointGeaocodeModel)
                            update();
                        }
                    } //start and end point
    
                    MapItemView {
                        model: routeBetweenPoints
                        delegate: Component {
                            MapRoute {
                                route: routeData
                                line.color: "red"
                                line.width: 10
                            }
                        }
                    }//linie, die beide punkte verbindet
    
                    GeocodeModel{
                        id: endPointGeaocodeModel
                        plugin: Plugin { name: "osm" }
                        query: "Sandakerveien 116, Oslo"
                        onLocationsChanged: {
                            if (count)
                                endPointImage.coordinate = get(0).coordinate;
                        }
                        Component.onCompleted: update()
                    } //suche den platz mit strasse und stadt
    
                    Rectangle{
    
                               id:_ifStartPointLongitude
                               width: 100
                               height: 20
                               border.color: 'gray'
                               border.width: 2
                               x: 900
                               y: 120
                               anchors.left: app_window.right
    
                               TextInput {
                                   id: txtPlainStartPointLongitude
                                   anchors.fill: parent
                                   anchors.margins: 4
                               }
    
                           }
    
    
                } //all widgets and items of map
            } //size and position of map
    } //Main application window
    
    

    Hier:

    GeocodeModel{
                        id: endPointGeaocodeModel
                        plugin: Plugin { name: "osm" }
                        query: "Sandakerveien 116, Oslo"
                        onLocationsChanged: {
                            if (count)
                                endPointImage.coordinate = get(0).coordinate;
                        }
                        Component.onCompleted: update()
                    } //suche den platz mit strasse und stadt
    

    I wrote by the query adress of QtCompany in Oslo, but i tried too adress in my city (Leipzig), but it still doesn't work. Ther marker won't be puted on the map, and i don't know why.

    And i wanna ask, if I can write it so:

    RouteModel {
                        id: routeBetweenPoints
                        plugin: Plugin { name: "osm" }
                        query: RouteQuery {id: routeQuery }
                        Component.onCompleted: {
                            routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
                            routeQuery.addWaypoint(endPointGeaocodeModel)
                            update();
                        }
                    } //start and end point
    

    Thanks for help and I hope, that someone know, how i can solve this problem.

    raven-worxR 1 Reply Last reply
    0
    • D DragonCoder

      Hi,
      i have a little problem with my Code.

      import QtQuick 2.9
      import QtQuick.Controls 2.2
      import QtQuick.Window 2.0
      import QtLocation 5.6
      import QtPositioning 5.6
      
      
      
      ApplicationWindow {
      
          id: app_window
          visible: true
          width: 1024
          height: 800
          title: qsTr("Navigation")
      
      
              PositionSource {
                  active: true
                  onPositionChanged: {
                      map_id.center = position.coordinate;
                  }
              }
      
      
              Rectangle {
                  id: mapRectangleID
                  width: 1024
                  height: 800
                  anchors.horizontalCenter: parent.horizontalCenter
                  anchors.verticalCenter: parent.verticalCenter
      
                  Map {
                      id: map_id
                      anchors.fill: parent
                      plugin: Plugin { name: "osm" }
                      center: QtPositioning.coordinate(51.320729390711975,12.280097007751465)
                      zoomLevel: 15
      
                      MapQuickItem {
                          //coordinate: QtPositioning.coordinate(59.91, 10.75)
                          sourceItem: Image {
                              id: endPointImage
                              source: "assets/marker.png"
                              width: 40.1
                              height: 34.3
                          } //size and position of maker
                          anchorPoint.x: endPointImage.width / 2
                          anchorPoint.y: endPointImage.height
                      } //marker
      
                   RouteModel {
                          id: routeBetweenPoints
                          plugin: Plugin { name: "osm" }
                          query: RouteQuery {id: routeQuery }
                          Component.onCompleted: {
                              routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
                              routeQuery.addWaypoint(QtPositioning.coordinate(51.3117764,12.280909000000065 ));
                              //routeQuery.addWaypoint(endPointGeaocodeModel)
                              update();
                          }
                      } //start and end point
      
                      MapItemView {
                          model: routeBetweenPoints
                          delegate: Component {
                              MapRoute {
                                  route: routeData
                                  line.color: "red"
                                  line.width: 10
                              }
                          }
                      }//linie, die beide punkte verbindet
      
                      GeocodeModel{
                          id: endPointGeaocodeModel
                          plugin: Plugin { name: "osm" }
                          query: "Sandakerveien 116, Oslo"
                          onLocationsChanged: {
                              if (count)
                                  endPointImage.coordinate = get(0).coordinate;
                          }
                          Component.onCompleted: update()
                      } //suche den platz mit strasse und stadt
      
                      Rectangle{
      
                                 id:_ifStartPointLongitude
                                 width: 100
                                 height: 20
                                 border.color: 'gray'
                                 border.width: 2
                                 x: 900
                                 y: 120
                                 anchors.left: app_window.right
      
                                 TextInput {
                                     id: txtPlainStartPointLongitude
                                     anchors.fill: parent
                                     anchors.margins: 4
                                 }
      
                             }
      
      
                  } //all widgets and items of map
              } //size and position of map
      } //Main application window
      
      

      Hier:

      GeocodeModel{
                          id: endPointGeaocodeModel
                          plugin: Plugin { name: "osm" }
                          query: "Sandakerveien 116, Oslo"
                          onLocationsChanged: {
                              if (count)
                                  endPointImage.coordinate = get(0).coordinate;
                          }
                          Component.onCompleted: update()
                      } //suche den platz mit strasse und stadt
      

      I wrote by the query adress of QtCompany in Oslo, but i tried too adress in my city (Leipzig), but it still doesn't work. Ther marker won't be puted on the map, and i don't know why.

      And i wanna ask, if I can write it so:

      RouteModel {
                          id: routeBetweenPoints
                          plugin: Plugin { name: "osm" }
                          query: RouteQuery {id: routeQuery }
                          Component.onCompleted: {
                              routeQuery.addWaypoint(QtPositioning.coordinate(51.318784,12.2773504 ));
                              routeQuery.addWaypoint(endPointGeaocodeModel)
                              update();
                          }
                      } //start and end point
      

      Thanks for help and I hope, that someone know, how i can solve this problem.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @DragonCoder
      what Qt version are you using, or better to what Qt version are you bound?

      I was using GeocodeModel (with OSM) myself a few days ago and encountered that it didn't return any results (even though the locations signal was triggered) with Qt 5.10, but worked with Qt 5.11

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

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

        I'm using qt 5.10

        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