Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved problem with QML and Google Maps Plugin

    QML and Qt Quick
    4
    8
    4349
    Loading More Posts
    • 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
      davidesalvetti last edited by davidesalvetti

      Hi all,

      I need to have google maps satellite view using qml. I have built the plugin created by @vladstelmahovsky and i got it working in debug mode, but when i switch to release mode the google map is not shown but the other part of the qml are visible.
      The following image can help you understand:
      0_1524583675934_oksatelllite.PNG

      0_1524583632561_nomap.PNG

      This is the code:

      import QtQuick 2.7
      import QtQuick.Controls 1.4
      import QtQuick.Window 2.0
      import QtLocation 5.6
      import QtPositioning 5.6
      
      Rectangle {
          id: mainWindow
          width: 512
          height: 512
          visible: true
      
          ListModel{
              id:dummyModel
              ListElement {
                  Latitude: 47.212047
                  Longitude: -1.551647
                  Label: "something"
                  Orientation: 0
                  Color:"transparent"
              }
         }
      
          Plugin {
              id: googleMaps
              name: "googlemaps" // "mapboxgl", "esri", ...
              // specify plugin parameters if necessary
               PluginParameter {
      
               }
      
          }
      
          Map {
              id: myMap
              anchors.fill: parent
              plugin: googleMaps
              activeMapType: supportedMapTypes[1]
      
              center: QtPositioning.coordinate(59.91, 10.75) // Oslo
              zoomLevel: 14
      
              MapItemView{
                  id:dynamicMapObject
                  model: dummyModel
                  delegate: MapQuickItem {
                      coordinate: QtPositioning.coordinate(Latitude,Longitude)
                      sourceItem:  Text{
                          width: 100
                          height: 50
                          text: model.Label
                          rotation: model.Orientation
                          opacity: 0.6
                          color: model.Color
                      }
                  }
              }
      
              MapPolyline {
                      line.width: 3
                      line.color: 'green'
                      path: [
                          { latitude: 59.92, longitude: 10.77 },
                          { latitude: 59.96, longitude: 10.78 },
                          { latitude: 59.99, longitude: 10.76 },
                          { latitude: 59.95, longitude: 10.74 }
                      ]
              }
      
              MapCircle {
                //a static item (fixed real dimension) always at 100m east of the map center
                id:prova
                center: myMap.center.atDistanceAndAzimuth(100,90)
                opacity:0.8
                color:"red"
                radius:30
      
              }
          }
      
          MouseArea {
                 anchors.fill: parent
                 acceptedButtons:  Qt.RightButton
      
                 onClicked: {
                      if (mouse.button === Qt.RightButton)
                      {
                          dummyModel.append({
                              "Latitude": myMap.toCoordinate(Qt.point(mouseX,mouseY)).latitude ,"Longitude": myMap.toCoordinate(Qt.point(mouseX,mouseY)).longitude ,
                              "Label": "abc" , "Color": "red",
                              "Orientation":Number(3), })
                      }
                 }
          }
      
          Button{
              id:buttonMap
              text:"Click to add name"
              onClicked: {
                  if(buttonMap.text == "Click to add name")
                  {
                      buttonMap.text = "Click to cancel name"
                      myMap.activeMapType = myMap.supportedMapTypes[3]
                  }
                  else
                  {
                      buttonMap.text = "Click to add name"
                      myMap.activeMapType = myMap.supportedMapTypes[1]
                  }
              }
          }
      
          GroupBox{
                 title:"map types"
                 ComboBox{
                     model:myMap.supportedMapTypes
                     textRole:"description"
                     onCurrentIndexChanged: myMap.activeMapType = myMap.supportedMapTypes[/*currentIndex*/0]
                 }
           }
      }
      

      When i try to change the MapType in the application output it appears thi message:

      qrc:/qml/qml/MapTrack.qml:119: Error: Cannot assign [undefined] to QDeclarativeGeoMapType*
      

      Somebody can give me some hint? I really don't know how to get it work also in release mode.

      Thanks in advance.

      V 1 Reply Last reply Reply Quote 0
      • V
        vladstelmahovsky @davidesalvetti last edited by

        @davidesalvetti I suppose, you have to build and install plugin in both debug and release modes. its very depends how exactly you building the plugin.

        D 1 Reply Last reply Reply Quote 3
        • D
          davidesalvetti @vladstelmahovsky last edited by

          @vladstelmahovsky Thank you very much, this was the answer! how stupid I was, I thought I had problem on my code side.
          Thank you again, now It works correctly also in release mode!

          1 Reply Last reply Reply Quote 0
          • tansgumus
            tansgumus last edited by

            Guys, which plugin you talked about?
            I looked into Qt source code but I couldn't find any Google Maps plugin!

            I only found 5 plugins for Qt Location while Google Maps isn't one of them!

            1 Reply Last reply Reply Quote 0
            • V
              VRonin last edited by

              source http://blog.qt.io/blog/2015/07/22/qtlocation-reloaded/ :

              Google TOS do not permit [Qt] to offer a Google specific geoservices plugin.

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              tansgumus 1 Reply Last reply Reply Quote 0
              • tansgumus
                tansgumus @VRonin last edited by

                @VRonin said in problem with QML and Google Maps Plugin:

                source http://blog.qt.io/blog/2015/07/22/qtlocation-reloaded/ :

                Google TOS do not permit [Qt] to offer a Google specific geoservices plugin.

                But how @davidesalvetti use it?

                V 1 Reply Last reply Reply Quote 0
                • V
                  VRonin @tansgumus last edited by

                  @tansgumus said in problem with QML and Google Maps Plugin:

                  But how @davidesalvetti use it?

                  @davidesalvetti said in problem with QML and Google Maps Plugin:

                  I have built the plugin created by @vladstelmahovsky

                  That's a 3rd party library hosted here: https://github.com/vladest/googlemaps

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  tansgumus 1 Reply Last reply Reply Quote 0
                  • tansgumus
                    tansgumus @VRonin last edited by

                    @VRonin Shame on you Google

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post