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. QML and google maps api key
Forum Update on Monday, May 27th 2025

QML and google maps api key

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 4.5k 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 13 Feb 2018, 07:47 last edited by
    #1

    Hi all,

    I'm having problems trying to set google maps api key for my project. Everything works well on debug mode but on release mode the map is not shown. I suppose this is because of the Api Key.
    I have created my project on google console and enabled the google maps api key so I think the problem is on the code side.
    This is my 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 {
                 name:"googlemaps.maps.apikey"
                 value:"*******My Api Key*********"
             }
    
        }
    
        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
    
            }
        }
    
        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]
               }
         }
    }
    

    I followed this topic (https://forum.qt.io/topic/66725/open-source-map-plug-in-for-qml/24).
    Am I doing something wrong writing the plugin parameters? Am I missing something?

    Is there a way to see if google api key has been setted well? Or something so that I can understand that the api key is wrong.

    Any suggestion would be helpful.
    Thanks in advance.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      davidesalvetti
      wrote on 26 Apr 2018, 14:07 last edited by
      #2

      The problem was not the apikey. Here is the answer to the question https://forum.qt.io/topic/90126/problem-with-qml-and-google-maps-plugin/3

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved