forked from VinokurovVE/tests
Remove @mui, move states into zustand store
This commit is contained in:
@ -2,14 +2,22 @@ import { create } from 'zustand';
|
||||
import { ToolType } from '../types/tools';
|
||||
import { Point } from 'ol/geom';
|
||||
import Map from 'ol/Map';
|
||||
import { Coordinate } from 'ol/coordinate';
|
||||
import { SatelliteMapsProvider } from '../interfaces/map';
|
||||
|
||||
interface MapState {
|
||||
currentTool: ToolType,
|
||||
measureType: "LineString" | "Polygon",
|
||||
measureShowSegments: boolean,
|
||||
measureClearPrevious: boolean,
|
||||
tipPoint: Point | null,
|
||||
map: Map | null
|
||||
currentTool: ToolType;
|
||||
measureType: "LineString" | "Polygon";
|
||||
measureShowSegments: boolean;
|
||||
measureClearPrevious: boolean;
|
||||
tipPoint: Point | null;
|
||||
map: Map | null;
|
||||
currentZ: number | undefined;
|
||||
currentX: number | undefined;
|
||||
currentY: number | undefined;
|
||||
currentCoordinate: Coordinate | null;
|
||||
statusText: string;
|
||||
satMapsProvider: SatelliteMapsProvider;
|
||||
}
|
||||
|
||||
export const useMapStore = create<MapState>(() => ({
|
||||
@ -18,16 +26,21 @@ export const useMapStore = create<MapState>(() => ({
|
||||
measureShowSegments: true,
|
||||
measureClearPrevious: true,
|
||||
tipPoint: null,
|
||||
map: null
|
||||
map: null,
|
||||
currentZ: undefined,
|
||||
currentX: undefined,
|
||||
currentY: undefined,
|
||||
currentCoordinate: null,
|
||||
statusText: '',
|
||||
satMapsProvider: 'custom'
|
||||
}));
|
||||
|
||||
const getMap = () => {
|
||||
return useMapStore.getState().map
|
||||
}
|
||||
|
||||
const setMap = (map: Map | null) => {
|
||||
useMapStore.setState(() => ({ map: map }))
|
||||
}
|
||||
const setCurrentZ = (z: number | undefined) => useMapStore.setState(() => ({ currentZ: z }))
|
||||
const setCurrentX = (x: number | undefined) => useMapStore.setState(() => ({ currentX: x }))
|
||||
const setCurrentY = (y: number | undefined) => useMapStore.setState(() => ({ currentY: y }))
|
||||
const setCurrentCoordinate = (c: Coordinate | null) => useMapStore.setState(() => ({ currentCoordinate: c }))
|
||||
const setStatusText = (t: string) => useMapStore.setState(() => ({ statusText: t }))
|
||||
const setSatMapsProvider = (p: SatelliteMapsProvider) => useMapStore.setState(() => ({ satMapsProvider: p }))
|
||||
|
||||
const setTipPoint = (tipPoint: Point | null) => {
|
||||
useMapStore.setState(() => ({ tipPoint: tipPoint }))
|
||||
@ -81,5 +94,11 @@ export {
|
||||
setMeasureType,
|
||||
getMeasureType,
|
||||
getTipPoint,
|
||||
setTipPoint
|
||||
setTipPoint,
|
||||
setCurrentZ,
|
||||
setCurrentX,
|
||||
setCurrentY,
|
||||
setCurrentCoordinate,
|
||||
setStatusText,
|
||||
setSatMapsProvider
|
||||
}
|
Reference in New Issue
Block a user