Ionic Google MAP API错误

时间:2018-01-17 12:04:24

标签: api google-maps ionic-framework ionic3

我使用IONIC-3并尝试为我的大学项目添加Google MAP API 我已经按照此Google MAP API说明,此处也提到了同样的问题Question,但对我不起作用

我的错误

  

无法解析GoogleMap的所有参数:(?,?)。在syntaxError

app.module.ts

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

  providers: [
    GoogleMaps,
    GoogleMap,]

addproject.html

<div class="map">
<div #map style="height: 100%;"></div>
</div>

addproject.ts

import { Componen } from '@angular/core';
import { IonicPage, NavController, NavParams,ViewController, Platform } from 'ionic-angular';
     import {
     GoogleMaps,
     GoogleMap,
     GoogleMapsEvent,
     GoogleMapOptions,
     CameraPosition,
     MarkerOptions,
     Marker
    } from '@ionic-native/google-maps';


        @IonicPage()
        @Component({
          selector: 'page-addproject',
          templateUrl: 'addproject.html',
        })
        export class AddprojectPage {
          @ViewChild('map')
          private mapElement:ElementRef;
          private map:GoogleMap;
          private location:LatLng;
      ionViewDidLoad() {
       this.loadMap();
   }
      map: GoogleMap;
      constructor(private googleMaps: GoogleMaps) { }
     loadMap() {

        let mapOptions: GoogleMapOptions = {
          camera: {
            target: {
              lat: 43.0741904,
              lng: -89.3809802
            },
            zoom: 18,
            tilt: 30
          }
        };

        this.map = this.googleMaps.create('map_canvas', mapOptions);

        // Wait the MAP_READY before using any methods.
        this.map.one(GoogleMapsEvent.MAP_READY)
          .then(() => {
            console.log('Map is ready!');

            // Now you can use all methods safely.
            this.map.addMarker({
                title: 'Ionic',
                icon: 'blue',
                animation: 'DROP',
                position: {
                  lat: 43.0741904,
                  lng: -89.3809802
                }
              })
              .then(marker => {
                marker.on(GoogleMapsEvent.MARKER_CLICK)
                  .subscribe(() => {
                    alert('clicked');
                  });
              });

          });
      }
    }
  

错误:无法解析GoogleMap的所有参数:(?,?)。       在syntaxError(http://localhost:8100/build/vendor.js:78533:34)       在CompileMetadataResolver._getDependenciesMetadata(http://localhost:8100/build/vendor.js:93614:35)       在CompileMetadataResolver._getTypeMetadata(http://localhost:8100/build/vendor.js:93449:26)       在CompileMetadataResolver._getInjectableMetadata(http://localhost:8100/build/vendor.js:93429:21)       在CompileMetadataResolver.getProviderMetadata(http://localhost:8100/build/vendor.js:93789:40)       在http://localhost:8100/build/vendor.js:93700:49       在Array.forEach()       在CompileMetadataResolver._getProvidersMetadata(http://localhost:8100/build/vendor.js:93660:19)       在CompileMetadataResolver.getNgModuleMetadata(http://localhost:8100/build/vendor.js:93228:50)       在JitCompiler._loadModules(http://localhost:8100/build/vendor.js:111609:87

0 个答案:

没有答案