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. problem with QML and Google Maps Plugin

problem with QML and Google Maps Plugin

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 4 Posters 5.8k 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.
  • D Offline
    D Offline
    davidesalvetti
    wrote on last edited by davidesalvetti
    #1

    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
    0
    • D 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 Offline
      V Offline
      vladstelmahovsky
      wrote on last edited by
      #2

      @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
      3
      • V vladstelmahovsky

        @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 Offline
        D Offline
        davidesalvetti
        wrote on last edited by
        #3

        @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
        0
        • tansgumusT Offline
          tansgumusT Offline
          tansgumus
          wrote on last edited by
          #4

          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
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            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

            tansgumusT 1 Reply Last reply
            0
            • VRoninV VRonin

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

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

              tansgumusT Offline
              tansgumusT Offline
              tansgumus
              wrote on last edited by
              #6

              @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?

              VRoninV 1 Reply Last reply
              0
              • tansgumusT tansgumus

                @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?

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                @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

                tansgumusT 1 Reply Last reply
                0
                • VRoninV VRonin

                  @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

                  tansgumusT Offline
                  tansgumusT Offline
                  tansgumus
                  wrote on last edited by
                  #8

                  @VRonin Shame on you Google

                  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