地图事件主要包括地图状态事件、地图覆盖物类型点击事件、地图手势事件事件。
mapController.addEventListener(MapEvent.MAPSTATUSCHANGESTART, () => {console.log('MapEvent.MAPSTATUSCHANGESTART');});mapController.addEventListener(MapEvent.MAPSTATUSCHANGE, () => {console.log('MapEvent.MAPSTATUSCHANGE');});mapController.addEventListener(MapEvent.MAPSTATUSCHANGEFINISH, () => {// 获取地图四至范围console.log('MapEvent.MAPSTATUSCHANGEFINISH', mapController.mapStatus.getGeoRound());});
this.mapController.addOverlayEventListener(EOverLayTypeName.MARKER,OverlayEvent.CLICK,(bundle:EventOverlayBundle)=>{let overlays = bundle.target as Array<Overlay>;if(overlays && overlays.length>0){overlays.forEach(item=>{if(item instanceof Marker){promptAction.showToast({message: 'Marker被点击',duration: 2000,});}});}});
// 点击事件this.mapController.addEventListener(MapEvent.CLICK, (event) => {event = event as EventBundle;const marker:Marker = new Marker({position: event.geo,icon: image});this.mapController?.addOverlay(marker);});// 双击事件this.mapController.addEventListener(MapEvent.DOUBLECLICK, (event) => {event = event as EventBundle;let left = event.left.toFixed();let top = event.top.toFixed();});this.mapController.addEventListener(MapEvent.PINCHSTART, (event) => {console.log('缩放事件开始');});this.mapController.addEventListener(MapEvent.PINCHUPDATE, (event) => {console.log('缩放事件过程中');});this.mapController.addEventListener(MapEvent.PINCHEND, (event) => {console.log('缩放事件结束');});this.mapController.addEventListener(MapEvent.ROTATIONSTART, (event) => {console.log('旋转事件开始');});this.mapController.addEventListener(MapEvent.ROTATIONUPDATE, (event) => {event = event as EventBundle;let rotationAngle = event.rotationAngle??0;console.log('旋转事件过程中',rotationAngle);});this.mapController.addEventListener(MapEvent.ROTATIONEND, (event) => {console.log('旋转事件结束');});this.mapController.addEventListener(MapEvent.TOUCHSTART, (event) => {console.log('移动事件开始');});this.mapController.addEventListener(MapEvent.TOUCHMOVE, (event) => {console.log('移动事件过程中');});this.mapController.addEventListener(MapEvent.TOUCHEND, (event) => {console.log('移动事件结束');});
上一篇
下一篇
本篇文章对您是否有帮助?