Qt qml 错误"Unable to assign [undefined] to QDeclarativeGeoMapType* "



我正在开发一个应用程序,我需要将谷歌地图添加到我的应用程序中。我正在使用Qt和QML。我生成了 API 密钥,但在运行代码后,它只加载了一个空白的灰色屏幕。有人可以推荐一些关于如何调试它的想法吗?只有这个错误消息很困难:

"无法将 [未定义] 分配给 QDeclarativeGeoMapType*">

Plugin {
           id: googleMaps
           name: "googlemaps" // "mapboxgl", "esri", ...
           // specify plugin parameters if necessary
            PluginParameter {
                name:"googlemaps.maps.apikey"
                value:"AIzaSyAl4e5Qaf5mYadK_BH3G7721yEcgt_Xcu0"
            }
       }
Map {
        id: myMap
        anchors.fill: parent
       plugin: googleMaps
//        plugin: hereMaps
        activeMapType: supportedMapTypes[2]
        center: QtPositioning.coordinate(19.997454, 73.789803)
        zoomLevel: 8
        GeocodeModel {
            id: geocodeModel
            plugin: myMap.plugin
            autoUpdate: false
            query: {
                geocodeModel.query = "India"
                geocodeModel.update()
                //console.debug()
            }
        }

正如您所说,您尚未安装 googlemaps 插件,因此您必须按照以下步骤操作:

git clone https://github.com/vladest/googlemaps.git
cd googlemaps/
mkdir build
cd build/
qmake ../
make
sudo make install

相关内容

最新更新