Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. google maps in qt
Forum Updated to NodeBB v4.3 + New Features

google maps in qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 7 Posters 9.3k Views 2 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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by
    #1

    what is the best way to use google maps in qt c++ preferably or qml ?

    ? 1 Reply Last reply
    0
    • QT_QT_QTQ Offline
      QT_QT_QTQ Offline
      QT_QT_QT
      wrote on last edited by
      #2

      Hi,

      You can use the Google Api that had already been provided.

      reference:
      https://developers.google.com/maps/web-services/overview#find-out-which-api-you-need

      1 Reply Last reply
      0
      • saitejS saitej

        what is the best way to use google maps in qt c++ preferably or qml ?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi! If you're fine with OpenStreetMap instead of Google Maps then you can use Maps and Navigation (QML).

        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          There's also a forum member that has implemented a backend for it. See this thread

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          saitejS 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            There's also a forum member that has implemented a backend for it. See this thread

            saitejS Offline
            saitejS Offline
            saitej
            wrote on last edited by
            #5

            @SGaist

            Hi I found this googlemaps plugin link in the thread you sent. As I am quiet new to Qt, could you give some hint on how to use this plugin along with Qtlocation C++.

            ? 1 Reply Last reply
            0
            • saitejS saitej

              @SGaist

              Hi I found this googlemaps plugin link in the thread you sent. As I am quiet new to Qt, could you give some hint on how to use this plugin along with Qtlocation C++.

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              @saitej Don't know what you want to do, just as a reminder: "Currently it is not possible to interact with maps via C++".

              saitejS 1 Reply Last reply
              0
              • ? A Former User

                @saitej Don't know what you want to do, just as a reminder: "Currently it is not possible to interact with maps via C++".

                saitejS Offline
                saitejS Offline
                saitej
                wrote on last edited by
                #7

                @Wieland
                Hi ..
                I want to display the current location as the first step using the googlemaps plugin either in qml or c++ which ever is possible.

                ? 1 Reply Last reply
                0
                • saitejS saitej

                  @Wieland
                  Hi ..
                  I want to display the current location as the first step using the googlemaps plugin either in qml or c++ which ever is possible.

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  @saitej You can't do this in C++ but QtQuick comes with the easy to use Map type.

                  saitejS 1 Reply Last reply
                  0
                  • ? A Former User

                    @saitej You can't do this in C++ but QtQuick comes with the easy to use Map type.

                    saitejS Offline
                    saitejS Offline
                    saitej
                    wrote on last edited by
                    #9

                    @Wieland

                    I tried the code from the link you had sent but am unable to view any map.
                    This is my main.qml code. The code doesn’t give an error but displays a blank window.

                    import QtPositioning 5.5
                    import QtLocation 5.6
                    import QtQuick 2.6
                    import QtQuick.Window 2.2
                    Window {
                        visible: true
                        width: 400
                        height: 600
                    
                        MouseArea {
                            anchors.fill: parent
                            onClicked: {
                                Qt.quit();
                            }
                        }
                        Plugin{
                            id:myplugin
                            name: "osm"
                        }
                        Map {
                            id: map
                            plugin: myplugin
                            center {
                                latitude: -27
                                longitude: 153
                            }
                            zoomLevel: map.minimumZoomLevel
                    
                            gesture.enabled: true
                        }
                    
                    
                    }
                    
                    
                    
                    
                    
                    ? 1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      khryleption
                      wrote on last edited by
                      #10

                      In my case, I used the API QMapControl Under LGPL license.
                      It's very easy to use.

                      1 Reply Last reply
                      1
                      • saitejS saitej

                        @Wieland

                        I tried the code from the link you had sent but am unable to view any map.
                        This is my main.qml code. The code doesn’t give an error but displays a blank window.

                        import QtPositioning 5.5
                        import QtLocation 5.6
                        import QtQuick 2.6
                        import QtQuick.Window 2.2
                        Window {
                            visible: true
                            width: 400
                            height: 600
                        
                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    Qt.quit();
                                }
                            }
                            Plugin{
                                id:myplugin
                                name: "osm"
                            }
                            Map {
                                id: map
                                plugin: myplugin
                                center {
                                    latitude: -27
                                    longitude: 153
                                }
                                zoomLevel: map.minimumZoomLevel
                        
                                gesture.enabled: true
                            }
                        
                        
                        }
                        
                        
                        
                        
                        
                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        @saitej Add anchors.fill: contentItem to your Map item ;-)

                        1 Reply Last reply
                        0
                        • saitejS Offline
                          saitejS Offline
                          saitej
                          wrote on last edited by
                          #12

                          Hi
                          I am having few basic issues with this code. I am unable to display the marker on the map.
                          Also, where do I write the signal showRoute(startCoordinate,endCoordinate)
                          It's giving me already declared error

                          I am used to c++ and I just started to use qml. so the doubts will be pretty basic so please bear with me

                          import QtPositioning 5.5
                          import QtLocation 5.6
                          import QtQuick 2.6
                          import QtQuick.Window 2.2
                          import QtQuick.Controls 1.4
                          import QtQuick.Layouts 1.3
                          
                          Window {
                              visible: true
                              width: 400
                              height: 600
                          
                              MouseArea {
                                  anchors.fill: parent
                                  //        onClicked: {
                                  //            Qt.quit();
                                  //        }
                              }
                          
                              //    splitview
                          
                              SplitView {
                                  anchors.fill: parent
                                  orientation: Qt.Vertical
                                  //rect1
                                  Rectangle {
                                      height: 150
                                      Layout.maximumHeight:  200
                                      //               color: "lightblue"
                          
                                      Label {
                                          id: label1
                                          text: "Latitude Start"
                                          x:0
                                          y:2
                          
                                      }
                                      Label{
                                          id : label2
                                          text: "Longitude Start"
                                          x:0
                                          y:25
                                      }
                          
                                      Label {
                                          id: label3
                                          text: "Latitude End"
                                          x:0
                                          y:50
                          
                                      }
                                      Label{
                                          id : label4
                                          text: "Longitude End"
                                          x:0
                                          y:75
                                      }
                                      //            textinputs
                                      TextInput {
                                          //                anchors.fill:
                                          id: input1
                                          x:150
                                          y:2
                                          font.pixelSize: 12; font.bold: false
                                          cursorVisible: true
                                          text:  "12.9716"
                                          //                acceptableInput:
                                          validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                          focus:true
                                      }
                                      TextInput {
                                          //                anchors.fill: contentItem
                                          id: input2
                                          x:150
                                          y:25
                                          font.pixelSize: 12; font.bold: false
                                          //                acceptableInput:
                                          validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                          //                focus:true
                                          echoMode: TextInput.Normal
                                          activeFocusOnTab: true
                                          text: "77.5946"
                                      }
                          
                                      TextInput {
                                          //                anchors.fill: contentItem
                                          id: input3
                                          x:150
                                          y:50
                                          font.pixelSize: 12; font.bold: false
                                          //                acceptableInput:
                                          validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                          //                focus:true
                                          echoMode: TextInput.Normal
                                          activeFocusOnTab: true
                                          text: "19.0760"
                          
                                      }
                          
                          
                                      TextInput {
                                          //                anchors.fill: contentItem
                                          id: input4
                                          x:150
                                          y:75
                                          font.pixelSize: 12; font.bold: false
                                          //                acceptableInput:
                                          validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                          //                focus:true
                                          echoMode: TextInput.Normal
                                          activeFocusOnTab: true
                                          text: "72.8777"
                          
                                      }
                          
                                      Button{
                                          id:goButton
                                          text : "GO!"
                                          anchors.horizontalCenter: parent.horizontalCenter
                                          y: 100
                                          onClicked: {
                                              var startCoordinate = QtPositioning.coordinate(parseFloat(input1.text),
                                                                                             parseFloat(input2.text));
                                              var endCoordinate = QtPositioning.coordinate(parseFloat(input3.text),
                                                                                           parseFloat(input4.text));
                                              if (startCoordinate.isValid && endCoordinate.isValid) {
                          
                                                  goButton.enabled = false;
                                                  showRoute(startCoordinate,endCoordinate)
                                              }
                          
                                          }
                          
                                      }
                                      Plugin{
                                          id:myplugin
                                          name: "osm"
                                      }
                          
                          
                          
                          
                          
                                  } //rectangle ends here
                          
                          
                          
                          
                                  Map {
                                      id: map
                                      plugin: myplugin
                                      center {
                          
                                          //                latitude: 12.9716 //
                                          //                longitude: 77.5946 //
                                          latitude :input1.text
                                          longitude:input2.text
                          
                                      }
                                      zoomLevel: 13
                                      anchors.fill: contentItem
                                      gesture.enabled: true
                                      //            property variant location: QtPositioning.coordinate( input1.text, input2.text)
                                      MapItemView {
                                          model:PlaceSearchModel
                                          delegate: MapQuickItem {
                                              id : marker
                                              coordinate: QtPositioning.coordinate( input1.text, input2.text)
                          
                                              anchorPoint.x: image.width * 0.5
                                              anchorPoint.y: image.height
                                              sourceItem: Image {
                                                  id: image
                                                  source: "qrc:/marker.png"
                          
                                              }
                          
                                          }
                          
                                      }
                          
                                  }
                          
                          
                              }
                          
                          
                          }
                          
                          
                          
                          
                          
                          bahman309B 1 Reply Last reply
                          0
                          • saitejS saitej

                            Hi
                            I am having few basic issues with this code. I am unable to display the marker on the map.
                            Also, where do I write the signal showRoute(startCoordinate,endCoordinate)
                            It's giving me already declared error

                            I am used to c++ and I just started to use qml. so the doubts will be pretty basic so please bear with me

                            import QtPositioning 5.5
                            import QtLocation 5.6
                            import QtQuick 2.6
                            import QtQuick.Window 2.2
                            import QtQuick.Controls 1.4
                            import QtQuick.Layouts 1.3
                            
                            Window {
                                visible: true
                                width: 400
                                height: 600
                            
                                MouseArea {
                                    anchors.fill: parent
                                    //        onClicked: {
                                    //            Qt.quit();
                                    //        }
                                }
                            
                                //    splitview
                            
                                SplitView {
                                    anchors.fill: parent
                                    orientation: Qt.Vertical
                                    //rect1
                                    Rectangle {
                                        height: 150
                                        Layout.maximumHeight:  200
                                        //               color: "lightblue"
                            
                                        Label {
                                            id: label1
                                            text: "Latitude Start"
                                            x:0
                                            y:2
                            
                                        }
                                        Label{
                                            id : label2
                                            text: "Longitude Start"
                                            x:0
                                            y:25
                                        }
                            
                                        Label {
                                            id: label3
                                            text: "Latitude End"
                                            x:0
                                            y:50
                            
                                        }
                                        Label{
                                            id : label4
                                            text: "Longitude End"
                                            x:0
                                            y:75
                                        }
                                        //            textinputs
                                        TextInput {
                                            //                anchors.fill:
                                            id: input1
                                            x:150
                                            y:2
                                            font.pixelSize: 12; font.bold: false
                                            cursorVisible: true
                                            text:  "12.9716"
                                            //                acceptableInput:
                                            validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                            focus:true
                                        }
                                        TextInput {
                                            //                anchors.fill: contentItem
                                            id: input2
                                            x:150
                                            y:25
                                            font.pixelSize: 12; font.bold: false
                                            //                acceptableInput:
                                            validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                            //                focus:true
                                            echoMode: TextInput.Normal
                                            activeFocusOnTab: true
                                            text: "77.5946"
                                        }
                            
                                        TextInput {
                                            //                anchors.fill: contentItem
                                            id: input3
                                            x:150
                                            y:50
                                            font.pixelSize: 12; font.bold: false
                                            //                acceptableInput:
                                            validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                            //                focus:true
                                            echoMode: TextInput.Normal
                                            activeFocusOnTab: true
                                            text: "19.0760"
                            
                                        }
                            
                            
                                        TextInput {
                                            //                anchors.fill: contentItem
                                            id: input4
                                            x:150
                                            y:75
                                            font.pixelSize: 12; font.bold: false
                                            //                acceptableInput:
                                            validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
                                            //                focus:true
                                            echoMode: TextInput.Normal
                                            activeFocusOnTab: true
                                            text: "72.8777"
                            
                                        }
                            
                                        Button{
                                            id:goButton
                                            text : "GO!"
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            y: 100
                                            onClicked: {
                                                var startCoordinate = QtPositioning.coordinate(parseFloat(input1.text),
                                                                                               parseFloat(input2.text));
                                                var endCoordinate = QtPositioning.coordinate(parseFloat(input3.text),
                                                                                             parseFloat(input4.text));
                                                if (startCoordinate.isValid && endCoordinate.isValid) {
                            
                                                    goButton.enabled = false;
                                                    showRoute(startCoordinate,endCoordinate)
                                                }
                            
                                            }
                            
                                        }
                                        Plugin{
                                            id:myplugin
                                            name: "osm"
                                        }
                            
                            
                            
                            
                            
                                    } //rectangle ends here
                            
                            
                            
                            
                                    Map {
                                        id: map
                                        plugin: myplugin
                                        center {
                            
                                            //                latitude: 12.9716 //
                                            //                longitude: 77.5946 //
                                            latitude :input1.text
                                            longitude:input2.text
                            
                                        }
                                        zoomLevel: 13
                                        anchors.fill: contentItem
                                        gesture.enabled: true
                                        //            property variant location: QtPositioning.coordinate( input1.text, input2.text)
                                        MapItemView {
                                            model:PlaceSearchModel
                                            delegate: MapQuickItem {
                                                id : marker
                                                coordinate: QtPositioning.coordinate( input1.text, input2.text)
                            
                                                anchorPoint.x: image.width * 0.5
                                                anchorPoint.y: image.height
                                                sourceItem: Image {
                                                    id: image
                                                    source: "qrc:/marker.png"
                            
                                                }
                            
                                            }
                            
                                        }
                            
                                    }
                            
                            
                                }
                            
                            
                            }
                            
                            
                            
                            
                            
                            bahman309B Offline
                            bahman309B Offline
                            bahman309
                            wrote on last edited by
                            #13

                            @saitej
                            anybody can to used google map api in QML
                            and used navigation and traffic from google map api ?

                            1 Reply Last reply
                            0
                            • Z Offline
                              Z Offline
                              zhangsi
                              wrote on last edited by
                              #14

                              QWebView::load

                              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