Ionic 2 GoogleMaps问题

时间:2017-04-15 00:07:14

标签: cordova google-maps ionic2 cordova-plugins

我正在尝试将Google地图添加到我的Ionic 2项目中,但却收到了一系列错误:

“错误:找不到:: GoogleMaps :: getMap的exec代理” “错误:找不到:: GoogleMaps :: exec的exec代理”

我从https://ionicframework.com/docs/native/google-maps/

复制了代码示例

import { Component } from '@angular/core';
import {
 GoogleMaps,
 GoogleMap,
 GoogleMapsEvent,
 LatLng,
 CameraPosition,
 MarkerOptions,
 Marker
} from '@ionic-native/google-maps';

@Component({
  selector: 'page-map',
  templateUrl: 'map.html'
})


export class MapPage {

 constructor(private googleMaps: GoogleMaps) {}

ionViewDidLoad() {
 this.loadMap();
}

loadMap() {

 let element: HTMLElement = document.getElementById('map');

 let map: GoogleMap = this.googleMaps.create(element);

 map.one(GoogleMapsEvent.MAP_READY).then(() => console.log('Map is ready!'));

 let ionic: LatLng = new LatLng(43.0741904,-89.3809802);

 let position: CameraPosition = {
   target: ionic,
   zoom: 18,
   tilt: 30
 };
 map.moveCamera(position);
 let markerOptions: MarkerOptions = {
   position: ionic,
   title: 'Ionic'
 };

  const marker: Marker = map.addMarker(markerOptions)
   .then((marker: Marker) => {
      marker.showInfoWindow();
    });
 }

}

0 个答案:

没有答案