feat(map): add coordinate zoom action
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user