feat(map): add coordinate zoom action

This commit is contained in:
2026-06-09 17:55:17 +08:00
parent 22afdbf2e8
commit 7d966a5e91
4 changed files with 128 additions and 0 deletions
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, type Dispatch, type SetStateAction } fr
import Feature from "ol/Feature";
import { GeoJSON } from "ol/format";
import Point from "ol/geom/Point";
import { transform } from "ol/proj";
import { bbox, featureCollection } from "@turf/turf";
import { useChatToolActionHandler } from "@/hooks/useChatToolActionHandler";
@@ -110,6 +111,18 @@ export const useToolbarChatActions = ({
locateFeatures(action.ids, action.layer, action.geometryKind);
break;
}
case "zoom_to_map": {
const center =
action.sourceCrs === "EPSG:4326"
? transform(action.coordinate, "EPSG:4326", "EPSG:3857")
: action.coordinate;
map?.getView().animate({
center,
zoom: action.zoom ?? map.getView().getZoom() ?? 18,
duration: action.durationMs ?? 1000,
});
break;
}
case "view_history": {
setChatPanelFeatureInfos(action.featureInfos);
setChatPanelType(action.dataType);