我正在做Ionic Native google地图。 但是,它不会检测地图拖动,camera_move,camera_move_start和camera_move_end的事件。 请告诉我们这个问题的原因以及解决方法。
离子信息 cli包:(D:\ github_3 \ greego-ion \ node_modules)
@ionic/cli-plugin-cordova : 1.6.0
@ionic/cli-utils : 1.7.0
ionic (Ionic CLI) : 3.7.0
全球套餐:
Cordova CLI : 7.0.1
本地包裹:
@ionic/app-scripts : 2.1.3
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.6.0
系统:
Android SDK Tools : 25.2.2
Node : v8.1.3
OS : Windows 10
npm : 5.0.4
我的代码
this.map = this.googleMaps.create(element, mapOptions);
// listen to MAP_READY event
// You must wait for this event to fire before adding something to the map or modifying it in anyway
this.map.one(GoogleMapsEvent.MAP_READY).then(
() => {
console.log('Map is ready!');
// Now you can add elements to the map like the marker
let lat: number;
let lng: number;
this.geolocation.getCurrentPosition().then((resp) => {
loader.dismiss();
lat = resp.coords.latitude;
lng = resp.coords.longitude;
console.log(resp);
// create CameraPosition
let position: CameraPosition = {
target: {
lat: lat,
lng: lng
},
zoom: 18,
tilt: 30
};
// move the map's camera to position
this.map.moveCamera(position);
// create new marker
let markerOptions: MarkerOptions = {
position: new LatLng(lat, lng)
};
this.map.addMarker(markerOptions)
.then((marker: Marker) => {
marker.showInfoWindow();
});
});
this.map.on(GoogleMapsEvent.CAMERA_MOVE_START).subscribe((endRes) => {
console.log(endRes, 'camera_move_start');
});
this.map.on(GoogleMapsEvent.CAMERA_MOVE).subscribe((endRes) => {
console.log(endRes, 'camera_move');
});
this.map.on(GoogleMapsEvent.CAMERA_MOVE_END).subscribe((endRes) => {
console.log(endRes, 'camera_move_end');
});
}).catch((err) => {
console.log(err);
});