【问题标题】:Runtime Error Can't resolve all parameters for GoogleMap: (?, ?)运行时错误无法解析 GoogleMap 的所有参数:(?, ?)
【发布时间】:2017-06-02 17:11:04
【问题描述】:

我正在尝试将一张基本地图加载到我的模板上。我只是按照这个指令https://ionicframework.com/docs/native/google-maps/ 来让我的地图工作。

但我收到了类似上述问题的错误。

这是我的代码

// Load map only after view is initialized
ngAfterViewInit() {
 this.loadMap();
}

loadMap() {
 // make sure to create following structure in your view.html file
 // and add a height (for example 100%) to it, else the map won't be visible
 // <ion-content>
 //  <div #map id="map" style="height:100%;"></div>
 // </ion-content>

 // create a new map by passing HTMLElement
 let element: HTMLElement = document.getElementById('map');

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

 // listen to MAP_READY event
 // You must wait for this event to fire before adding something to the map or modifying it in anyway
 map.one(GoogleMapsEvent.MAP_READY).then(
   () => {
     console.log('Map is ready!');
     // Now you can add elements to the map like the marker
   }
 );

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

 // create CameraPosition
 let position: CameraPosition = {
   target: ionic,
   zoom: 18,
   tilt: 30
 };

 // move the map's camera to position
 map.moveCamera(position);

 }

}

我得到空白屏幕我无法在我的 app.compontent.ts 文件中打印 console.log

【问题讨论】:

    标签: angular cordova google-maps ionic3


    【解决方案1】:

    我更改了我的 app.module.ts 文件

    import {GoogleMaps,GoogleMap} from '@ionic-native/google-maps';
    
    providers: [
        StatusBar,
        SplashScreen,
        GoogleMaps,
        GoogleMap
        {provide: ErrorHandler, useClass: IonicErrorHandler}
      ]
    

    到这里

    import {GoogleMaps} from '@ionic-native/google-maps';
    
    providers: [
        StatusBar,
        SplashScreen,
        GoogleMaps
        {provide: ErrorHandler, useClass: IonicErrorHandler}
      ]
    

    只需从我的提供程序中删除 googleMap 并导入我就可以正常工作

    【讨论】:

    • 也为我工作。谢谢
    • @Mohan Gopi 在更改以上行后对我不起作用?
    猜你喜欢
    • 1970-01-01
    • 2019-04-25
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多