优化MapSelector
parent
d3e64e0004
commit
a2843dc788
|
|
@ -22,6 +22,8 @@ export interface MapSelectorProps {
|
||||||
area?: string;
|
area?: string;
|
||||||
/** 是否显示所属区域 */
|
/** 是否显示所属区域 */
|
||||||
showArea?: boolean;
|
showArea?: boolean;
|
||||||
|
/** 是否只查看 */
|
||||||
|
disable?: boolean;
|
||||||
/** 确认选择回调 */
|
/** 确认选择回调 */
|
||||||
onConfirm?: (longitude: number | string, latitude: number | string, extra: { area: string }) => void;
|
onConfirm?: (longitude: number | string, latitude: number | string, extra: { area: string }) => void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ const MapSelector = (props) => {
|
||||||
onConfirm,
|
onConfirm,
|
||||||
area = "",
|
area = "",
|
||||||
showArea = false,
|
showArea = false,
|
||||||
|
disable = false,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const mapContainerRef = useRef(null);
|
const mapContainerRef = useRef(null);
|
||||||
|
|
@ -66,14 +67,16 @@ const MapSelector = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加点击事件
|
// 添加点击事件
|
||||||
map.addEventListener("click", (event) => {
|
if (!disable) {
|
||||||
map.clearOverlays();
|
map.addEventListener("click", (event) => {
|
||||||
const point = new window.BMapGL.Point(event.latlng.lng, event.latlng.lat);
|
map.clearOverlays();
|
||||||
const marker = new window.BMapGL.Marker(point);
|
const point = new window.BMapGL.Point(event.latlng.lng, event.latlng.lat);
|
||||||
map.addOverlay(marker);
|
const marker = new window.BMapGL.Marker(point);
|
||||||
setCurrentLatitude(event.latlng.lat);
|
map.addOverlay(marker);
|
||||||
setCurrentLongitude(event.latlng.lng);
|
setCurrentLatitude(event.latlng.lat);
|
||||||
});
|
setCurrentLongitude(event.latlng.lng);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
@ -149,10 +152,19 @@ const MapSelector = (props) => {
|
||||||
open={visible}
|
open={visible}
|
||||||
title="坐标"
|
title="坐标"
|
||||||
onCancel={handleClose}
|
onCancel={handleClose}
|
||||||
onOk={handleConfirm}
|
|
||||||
width={1000}
|
width={1000}
|
||||||
destroyOnHidden={false}
|
destroyOnHidden={false}
|
||||||
afterClose={handleAfterClose}
|
afterClose={handleAfterClose}
|
||||||
|
footer={[
|
||||||
|
<Button key="back" onClick={handleClose}>
|
||||||
|
取消
|
||||||
|
</Button>,
|
||||||
|
!disable && (
|
||||||
|
<Button key="submit" type="primary" onClick={handleConfirm}>
|
||||||
|
确定
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
||||||
{
|
{
|
||||||
|
|
@ -169,20 +181,24 @@ const MapSelector = (props) => {
|
||||||
</Row>
|
</Row>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
<Row gutter={24}>
|
{
|
||||||
<Col span={12}>
|
!disable && (
|
||||||
<Form.Item label="关键字搜索">
|
<Row gutter={24}>
|
||||||
<Input value={localSearch} onChange={e => setLocalSearch(e.target.value)} allowClear />
|
<Col span={12}>
|
||||||
</Form.Item>
|
<Form.Item label="关键字搜索">
|
||||||
</Col>
|
<Input value={localSearch} onChange={e => setLocalSearch(e.target.value)} allowClear />
|
||||||
<Col span={12}>
|
</Form.Item>
|
||||||
<Form.Item label=" " colon={false}>
|
</Col>
|
||||||
<Button type="primary" onClick={handleLocalSearch}>
|
<Col span={12}>
|
||||||
搜索
|
<Form.Item label=" " colon={false}>
|
||||||
</Button>
|
<Button type="primary" onClick={handleLocalSearch}>
|
||||||
</Form.Item>
|
搜索
|
||||||
</Col>
|
</Button>
|
||||||
</Row>
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
}
|
||||||
<Row gutter={24}>
|
<Row gutter={24}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item label="经度">
|
<Form.Item label="经度">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue