diff --git a/src/modules/Router.ts b/src/modules/Router.ts index da6b4b8..545a6a9 100644 --- a/src/modules/Router.ts +++ b/src/modules/Router.ts @@ -1,7 +1,8 @@ -import { Marker } from 'leaflet'; +import { Map, Marker } from 'leaflet'; import * as Routing from 'leaflet-routing-machine/src/index'; import { CLIENT } from '$config/frontend'; import { DomMarker } from '$utils/DomMarker'; +import { editor } from "$modules/Editor"; interface ILatLng { lat: number, lng: number @@ -11,19 +12,17 @@ interface IWaypoint { latLng: ILatLng } -interface IRouter { - waypoints: Array; - lockMapClicks: (status: boolean) => void; - setRouterPoints: (count: void) => void; - pushPolyPoints: (coordinates: Array<{ lat: number, lng: number }>) => void; - router: Routing; - clearAll: () => void; +interface Props { + map: Map, + setRouterPoints: typeof editor.setRouterPoints, + pushPolyPoints: typeof editor.pushPolyPoints, + lockMapClicks: typeof editor.lockMapClicks; } -export class Router implements IRouter { +export class Router { constructor({ map, lockMapClicks, setRouterPoints, pushPolyPoints - }) { + }: Props) { this.waypoints = []; this.lockMapClicks = lockMapClicks; this.setRouterPoints = setRouterPoints; @@ -149,8 +148,8 @@ export class Router implements IRouter { }; waypoints: Array = []; - lockMapClicks: (status: boolean) => void; - setRouterPoints: (count: void) => void; - pushPolyPoints: (coordinates: Array<{ lat: number, lng: number }>) => void; + lockMapClicks: Props['lockMapClicks']; + setRouterPoints: Props['setRouterPoints']; + pushPolyPoints: Props['pushPolyPoints']; router: Routing; } diff --git a/src/modules/Sticker.tsx b/src/modules/Sticker.tsx index c8f11d9..9c1ae64 100644 --- a/src/modules/Sticker.tsx +++ b/src/modules/Sticker.tsx @@ -9,6 +9,7 @@ import classnames from 'classnames'; import { getLabelDirection } from '$utils/geom'; import { ILatLng } from "$modules/Stickers"; import { IRootState } from "$redux/user/reducer"; +import { editor } from "$modules/Editor"; const getX = e => ( e.touches && e.touches.length > 0 @@ -25,34 +26,18 @@ export interface IStickerDump { text?: string, } -interface IStickerson { - element: HTMLDivElement; - stickerImage: HTMLDivElement; - stickerArrow: HTMLDivElement; - marker: Marker; - text: string; - latlng: { lat: number, lng: number }; - angle: number; - isDragging: boolean; - map: Map; - sticker: string; - set: string; - triggerOnChange: () => void; - direction: string; - deleteSticker: (sticker: this) => void; - lockMapClicks: (x: boolean) => void; -} - interface Props { latlng: ILatLng; - deleteSticker: (sticker: this) => void; map: Map; - lockMapClicks: (status: boolean) => void; sticker: IRootState['activeSticker']['sticker']; set: IRootState['activeSticker']['set']; - triggerOnChange: () => void; angle?: number; text?: string; + + deleteSticker: (sticker: this) => void; + + triggerOnChange: typeof editor.triggerOnChange; + lockMapClicks: typeof editor.lockMapClicks; } export class Sticker { diff --git a/src/modules/Stickers.ts b/src/modules/Stickers.ts index df65037..5525b60 100644 --- a/src/modules/Stickers.ts +++ b/src/modules/Stickers.ts @@ -2,7 +2,7 @@ import { LayerGroup, layerGroup, Map } from 'leaflet'; import { IStickerDump, Sticker } from '$modules/Sticker'; import { MarkerClusterGroup } from 'leaflet.markercluster/dist/leaflet.markercluster-src.js'; import { clusterIcon } from '$utils/clusterIcon'; -import { Editor } from "$modules/Editor"; +import { editor, Editor } from "$modules/Editor"; export interface ILatLng { lat: number, @@ -12,8 +12,9 @@ export interface ILatLng { interface Props { editor: Editor; map: Map; - triggerOnChange: () => void; - lockMapClicks: (x: boolean) => void; + + triggerOnChange: typeof editor.triggerOnChange; + lockMapClicks: typeof editor.lockMapClicks; } export class Stickers {