Ionic Native尝试访问GoogleMaps插件,但它没有安装



我目前正在尝试通过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!");
    });
  }
}

主要适应离子原生谷歌地图教程的建议。我已经反复卸载并再次安装了离子原生谷歌地图插件,但它似乎不起作用。知道我可能做错了什么吗?

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

相关内容

  • 没有找到相关文章

最新更新