地图打点和清除 打点标志
This commit is contained in:
@@ -123,7 +123,8 @@ export default function DeviceStatusPage() {
|
||||
const [isSaveModalVisible, setIsSaveModalVisible] = useState(false); // 保存模态框可见性
|
||||
const [plotName, setPlotName] = useState(''); // 地块名称
|
||||
const [isSaving, setIsSaving] = useState(false); // 是否正在保存
|
||||
const mapRef = useRef(null); // 地图 ref
|
||||
const mapRef = useRef(null);
|
||||
const clearDrawRef = useRef<(() => void) | null>(null); // 地图 ref
|
||||
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
@@ -658,13 +659,34 @@ export default function DeviceStatusPage() {
|
||||
messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 }));
|
||||
};
|
||||
|
||||
// Map click to add marked point
|
||||
const handleMapMarkPoint = (point) => {
|
||||
setMarkedPoints([...markedPoints, { lon: Number(point.lon), lat: Number(point.lat) }]);
|
||||
messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 }));
|
||||
};
|
||||
|
||||
// 清空标记点
|
||||
const handleClearPoints = () => {
|
||||
setMarkedPoints([]);
|
||||
setCompleteFlag(false);
|
||||
setSavePath(null);
|
||||
clearDrawRef.current?.();
|
||||
};
|
||||
|
||||
const getPathPoints = (coords) => {
|
||||
console.log("getPathPoints", coords)
|
||||
//setPathPoints(coords);
|
||||
if (!coords || coords.length === 0) return;
|
||||
const newWps = coords.map((p, i) => ({
|
||||
id: i + 1,
|
||||
lon: p.lon.toFixed(6),
|
||||
lat: p.lat.toFixed(6),
|
||||
}));
|
||||
console.log("newWps", newWps)
|
||||
//setWaypoints(newWps);
|
||||
};
|
||||
|
||||
|
||||
// 完成功能 - 调用路径规划接口
|
||||
const handleSave = async () => {
|
||||
if (!plotName.trim()) {
|
||||
@@ -1034,11 +1056,13 @@ export default function DeviceStatusPage() {
|
||||
markedPoints={markedPoints}
|
||||
realtimePosition={realtimePosition}
|
||||
realtimeType={realtimeType}
|
||||
onPathChange={getPathPoints}
|
||||
|
||||
drawRealTime={true}
|
||||
finishPoint={arrivedPoint}
|
||||
ifClearNavLine={clearNavLine}
|
||||
ifClearPlanLine={clearPlanLine}
|
||||
from="deviceStatus"
|
||||
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
@@ -1324,7 +1348,7 @@ export default function DeviceStatusPage() {
|
||||
finishPoint={arrivedPoint}
|
||||
ifClearNavLine={clearNavLine}
|
||||
ifClearPlanLine={clearPlanLine}
|
||||
from="deviceStatus"
|
||||
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user