From a2843dc78873c6069dff872a1a7f1ecbd17743a1 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Fri, 14 Nov 2025 15:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96MapSelector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Map/MapSelector.d.ts | 2 ++ components/Map/MapSelector.js | 62 +++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/components/Map/MapSelector.d.ts b/components/Map/MapSelector.d.ts index e40da3e..aaeac97 100644 --- a/components/Map/MapSelector.d.ts +++ b/components/Map/MapSelector.d.ts @@ -22,6 +22,8 @@ export interface MapSelectorProps { area?: string; /** 是否显示所属区域 */ showArea?: boolean; + /** 是否只查看 */ + disable?: boolean; /** 确认选择回调 */ onConfirm?: (longitude: number | string, latitude: number | string, extra: { area: string }) => void; } diff --git a/components/Map/MapSelector.js b/components/Map/MapSelector.js index 2639f8d..d228c02 100644 --- a/components/Map/MapSelector.js +++ b/components/Map/MapSelector.js @@ -13,6 +13,7 @@ const MapSelector = (props) => { onConfirm, area = "", showArea = false, + disable = false, } = props; const mapContainerRef = useRef(null); @@ -66,14 +67,16 @@ const MapSelector = (props) => { } // 添加点击事件 - map.addEventListener("click", (event) => { - map.clearOverlays(); - const point = new window.BMapGL.Point(event.latlng.lng, event.latlng.lat); - const marker = new window.BMapGL.Marker(point); - map.addOverlay(marker); - setCurrentLatitude(event.latlng.lat); - setCurrentLongitude(event.latlng.lng); - }); + if (!disable) { + map.addEventListener("click", (event) => { + map.clearOverlays(); + const point = new window.BMapGL.Point(event.latlng.lng, event.latlng.lat); + const marker = new window.BMapGL.Marker(point); + map.addOverlay(marker); + setCurrentLatitude(event.latlng.lat); + setCurrentLongitude(event.latlng.lng); + }); + } } setLoading(false); @@ -149,10 +152,19 @@ const MapSelector = (props) => { open={visible} title="坐标" onCancel={handleClose} - onOk={handleConfirm} width={1000} destroyOnHidden={false} afterClose={handleAfterClose} + footer={[ + , + !disable && ( + + ), + ]} >