Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

problem with QML and Google Maps Plugin



  • 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.



  • @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.



  • @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!



  • 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!



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

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



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



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



  • @VRonin Shame on you Google


Log in to reply