QML and google maps api key
-
wrote on 13 Feb 2018, 07:47 last edited by
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. -
wrote on 26 Apr 2018, 14:07 last edited by
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