This commit is contained in:
cracklesparkle
2024-12-16 10:50:35 +09:00
parent eeae97288a
commit 87866e4e51
19 changed files with 2419487 additions and 499 deletions

View File

@ -11,7 +11,7 @@ import VectorSource from "ol/source/Vector";
import proj4 from "proj4";
import { firstStyleFunction, fourthStyleFunction, selectStyle, styleFunction, thirdStyleFunction } from "./MapStyles";
import { Type } from "ol/geom/Geometry";
import { Draw, Modify, Snap } from "ol/interaction";
import { Draw, Modify, Snap, Translate } from "ol/interaction";
import { noModifierKeys } from "ol/events/condition";
import { IGeometryType, IRectCoords } from "../../interfaces/map";
import { uploadCoordinates } from "../../actions/map";
@ -22,6 +22,7 @@ import { fromCircle } from "ol/geom/Polygon";
import { measureStyleFunction, modifyStyle } from "./Measure/MeasureStyles";
import { getCurrentTool, getMeasureClearPrevious, getMeasureType, getTipPoint, setStatusText } from "../../store/map";
import { MutableRefObject } from "react";
import { setSelectedRegion } from "../../store/objects";
export function processLine(
line: ILine,
@ -179,6 +180,7 @@ export const updateImageSource = (
export const addInteractions = (
drawingLayerSource: React.MutableRefObject<VectorSource<Feature<Geometry>>>,
translate: React.MutableRefObject<Translate | null>,
draw: React.MutableRefObject<Draw | null>,
map: React.MutableRefObject<Map | null>,
snap: React.MutableRefObject<Snap | null>,
@ -191,7 +193,7 @@ export const addInteractions = (
const measureType = getMeasureType()
const tipPoint = getTipPoint()
if (currentTool !== 'Measure') {
if (currentTool !== 'Measure' && currentTool !== 'Mover') {
draw.current = new Draw({
source: drawingLayerSource.current,
type: currentTool as Type,
@ -255,6 +257,11 @@ export const addInteractions = (
measureModify.current.setActive(true);
map.current?.addInteraction(measureDraw.current);
}
if (currentTool == 'Mover') {
translate.current = new Translate()
map?.current?.addInteraction(translate.current)
}
}
export function regionsInit(
@ -274,6 +281,9 @@ export function regionsInit(
// Zoom to the selected feature
zoomToFeature(map, selectedRegion.current)
if (feature.get('id')) {
setSelectedRegion(feature.get('id'))
}
return true
} else return false
});