更新时间:2026/02/27 14:50
UI类型控件
目前支持用户设置缩放控件、定位控件、比例尺控件的显示/隐藏以及显示位置。
JavaScript
Button('显示', { type: ButtonType.Capsule, stateEffect: true }).onClick(() => { emitter.emit({ eventId: Event.ScaleCom }, { data: { show: true, mapViewId: this.mapController?.mapViewId } }) emitter.emit({ eventId: Event.ZoomCom }, { data: { show: true, mapViewId: this.mapController?.mapViewId } }) }).borderRadius(8) .backgroundColor(0x317aff) .margin(5) Button('隐藏', { type: ButtonType.Capsule, stateEffect: true }).onClick(() => { emitter.emit({ eventId: Event.ScaleCom }, { data: { show: false, mapViewId: this.mapController?.mapViewId } }) emitter.emit({ eventId: Event.ZoomCom }, { data: { show: false, mapViewId: this.mapController?.mapViewId } }) Button('改变位置', { type: ButtonType.Capsule, stateEffect: true }).onClick(() => { emitter.emit({ eventId: Event.ScaleCom }, { data: { show: true, mapViewId: this.mapController?.mapViewId, y: -200 } }) emitter.emit({ eventId: Event.ZoomCom }, { data: { show: true, mapViewId: this.mapController?.mapViewId, y: -200 } }) }).borderRadius(8) .backgroundColor(0x317aff) .margin(5)引擎类型控件
目前支持指北针控件、定位图标控件的属性设置。
指北针
可以设置显示位置、是否显示
JavaScript
this.mapController.mapStatus.setRotate(30).setCenterPoint(new LatLng(30, 112)).refresh();this.compass = this.mapController.getLayerByTag(SysEnum.LayerTag.COMPASS) as CompassLayer;this.compass && (this.compass.x = 64);this.compass && (this.compass.y = 64);// 设置显示/隐藏// this.compass && (this.compass.visible = true);定位图标
可以设置显示位置、是否显示以及图标指向、扩散范围
JavaScript
let result = this.mapController.getLayerByTag(SysEnum.LayerTag.LOCATION);if(result){ // 设置定位图标位置、指向以及范围 this.loc = result as LocationLayer; this.loc.location = new LatLng(30, 112); this.loc.direction = 90; // 单位米 this.loc.radius = 1000;}本篇文章对您是否有帮助?