运行时错误无法解析 GoogleMap 的所有参数:(?,?)
Runtime Error Can't resolve all parameters for GoogleMap: (?, ?)
我正在尝试将基本地图加载到我的模板中。我只是按照此说明 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);
}
}
i am getting blank screen i am not able to print console.log in my app.compontent.ts file
我更改了我的 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 并导入我就可以了
我正在尝试将基本地图加载到我的模板中。我只是按照此说明 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);
}
}
i am getting blank screen i am not able to print console.log in my app.compontent.ts file
我更改了我的 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 并导入我就可以了