gpt4 book ai didi

ios - Ionic Native 尝试访问 GoogleMaps 插件,但未安装

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:47:23 27 4
gpt4 key购买 nike

我目前正在尝试通过 ionic 实现 GoogleMaps。我是一个完全的初学者,所以请小心!我收到一个错误:

console.warn: Native: tried accessing the GoogleMaps plugin but it's not installed. 

每当我运行时

ionic cordova build ios
ionic cordova emulate ios -lc

我在 home.ts 中的代码如下所示:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { GoogleMaps, GoogleMap, GoogleMapsEvent, LatLng } from '@ionic-native/google-maps';


@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {

map: GoogleMap;

constructor(public navCtrl: NavController, public geolocation: Geolocation, private googleMaps: GoogleMaps) {
console.log("Home page creator loaded");
}

ngAfterViewInit() {
console.log("ngAfterViewInit loaded");

let mapEle = document.getElementById('map');
let location = new LatLng(-34.9290,138.6010);
let mapOpt = {
center: {lat: -34.397, lng: 150.644},
zoom: 8,
};

this.map = this.googleMaps.create(mapEle, mapOpt);
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
console.log("Map seems ready!");
});
}
}

主要适应 ionic 原生 GoogleMaps 教程的建议。我已经重复卸载并安装了 ionic-native google-maps plugin再次,但它似乎不起作用。知道我可能做错了什么吗?

最佳答案

ngAfterViewInit() {
this.platform.ready().then(() => {
this.loadMap();
});
}

关于ios - Ionic Native 尝试访问 GoogleMaps 插件,但未安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44218576/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com