From b0d74eb4741e1d69fd5ba61f5e4a18117bd73997 Mon Sep 17 00:00:00 2001 From: wangxiufeng01 Date: Thu, 6 Feb 2025 20:36:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20location=20picker=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=8E=A7=E4=BB=B6=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/BaiduMapPicker.tsx | 11 +++++++---- packages/amis-ui/src/components/LocationPicker.tsx | 7 ++++++- packages/amis/src/renderers/Form/LocationPicker.tsx | 9 ++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/amis-ui/src/components/BaiduMapPicker.tsx b/packages/amis-ui/src/components/BaiduMapPicker.tsx index 5183adbbeef..68a5aa588cb 100644 --- a/packages/amis-ui/src/components/BaiduMapPicker.tsx +++ b/packages/amis-ui/src/components/BaiduMapPicker.tsx @@ -43,6 +43,7 @@ interface MapPickerProps { onlySelectCurrentLoc?: boolean; showSug?: boolean; showGeoLoc?: boolean; + hideViewControl?: boolean; mapStyle?: React.CSSProperties; } @@ -138,10 +139,12 @@ export class BaiduMapPicker extends React.Component< map.centerAndZoom(point, zoom); } - map.addControl( - // @ts-ignore - new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_SMALL}) - ); + if (!this.props.hideViewControl) { + map.addControl( + // @ts-ignore + new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_SMALL}) + ); + } const geolocationControl = new BMap.GeolocationControl(); geolocationControl.addEventListener('locationSuccess', (e: any) => { diff --git a/packages/amis-ui/src/components/LocationPicker.tsx b/packages/amis-ui/src/components/LocationPicker.tsx index f2494bcb03d..053988f7ae8 100644 --- a/packages/amis-ui/src/components/LocationPicker.tsx +++ b/packages/amis-ui/src/components/LocationPicker.tsx @@ -30,6 +30,7 @@ export interface LocationProps extends ThemeProps, LocaleProps { popOverContainer?: any; autoSelectCurrentLoc?: boolean; onlySelectCurrentLoc?: boolean; + hideViewControl?: boolean; // 隐藏地图控件,默认为false,即显示控件 } export interface LocationState { @@ -167,7 +168,8 @@ export class LocationPicker extends React.Component< ak, mobileUI, autoSelectCurrentLoc, - onlySelectCurrentLoc + onlySelectCurrentLoc, + hideViewControl = false } = this.props; const __ = this.props.translate; const {isFocused, isOpened} = this.state; @@ -183,6 +185,7 @@ export class LocationPicker extends React.Component< autoSelectCurrentLoc={autoSelectCurrentLoc} onlySelectCurrentLoc={onlySelectCurrentLoc} onChange={this.handleChange} + hideViewControl={hideViewControl} /> ); case 'gaode': @@ -254,6 +257,7 @@ export class LocationPicker extends React.Component< autoSelectCurrentLoc={autoSelectCurrentLoc} onlySelectCurrentLoc={onlySelectCurrentLoc} onChange={this.handleTempChange} + hideViewControl={hideViewControl} /> ) : ( {__('{{vendor}} 地图控件不支持', {vendor})} @@ -282,6 +286,7 @@ export class LocationPicker extends React.Component< autoSelectCurrentLoc={autoSelectCurrentLoc} onlySelectCurrentLoc={onlySelectCurrentLoc} onChange={this.handleChange} + hideViewControl={hideViewControl} /> ) : ( {__('{{vendor}} 地图控件不支持', {vendor})} diff --git a/packages/amis/src/renderers/Form/LocationPicker.tsx b/packages/amis/src/renderers/Form/LocationPicker.tsx index 2a3f2a5b9b8..83a0b5ba324 100644 --- a/packages/amis/src/renderers/Form/LocationPicker.tsx +++ b/packages/amis/src/renderers/Form/LocationPicker.tsx @@ -53,6 +53,11 @@ export interface LocationControlSchema extends FormBaseControlSchema { * 备注:区分下现有的placeholder(“请选择位置”) */ getLocationPlaceholder?: string; + + /** + * 是否隐藏地图控制组件,默认为false + */ + hideViewControl?: boolean; } export interface LocationControlProps @@ -144,7 +149,8 @@ export class LocationControl extends React.Component { value, staticSchema, ak, - coordinatesType + coordinatesType, + hideViewControl = false } = this.props; const __ = this.props.translate; @@ -173,6 +179,7 @@ export class LocationControl extends React.Component { showSug={false} showGeoLoc={staticSchema.showGeoLoc} mapStyle={staticSchema.mapStyle} + hideViewControl={hideViewControl} /> ) : (