ts for editor, router, stickers

This commit is contained in:
muerwre 2019-02-20 17:57:45 +07:00
parent 628b96c4ab
commit 4aff0f7eb1
3 changed files with 22 additions and 37 deletions

View file

@ -1,7 +1,8 @@
import { Marker } from 'leaflet'; import { Map, Marker } from 'leaflet';
import * as Routing from 'leaflet-routing-machine/src/index'; import * as Routing from 'leaflet-routing-machine/src/index';
import { CLIENT } from '$config/frontend'; import { CLIENT } from '$config/frontend';
import { DomMarker } from '$utils/DomMarker'; import { DomMarker } from '$utils/DomMarker';
import { editor } from "$modules/Editor";
interface ILatLng { interface ILatLng {
lat: number, lng: number lat: number, lng: number
@ -11,19 +12,17 @@ interface IWaypoint {
latLng: ILatLng latLng: ILatLng
} }
interface IRouter { interface Props {
waypoints: Array<IWaypoint>; map: Map,
lockMapClicks: (status: boolean) => void; setRouterPoints: typeof editor.setRouterPoints,
setRouterPoints: (count: void) => void; pushPolyPoints: typeof editor.pushPolyPoints,
pushPolyPoints: (coordinates: Array<{ lat: number, lng: number }>) => void; lockMapClicks: typeof editor.lockMapClicks;
router: Routing;
clearAll: () => void;
} }
export class Router implements IRouter { export class Router {
constructor({ constructor({
map, lockMapClicks, setRouterPoints, pushPolyPoints map, lockMapClicks, setRouterPoints, pushPolyPoints
}) { }: Props) {
this.waypoints = []; this.waypoints = [];
this.lockMapClicks = lockMapClicks; this.lockMapClicks = lockMapClicks;
this.setRouterPoints = setRouterPoints; this.setRouterPoints = setRouterPoints;
@ -149,8 +148,8 @@ export class Router implements IRouter {
}; };
waypoints: Array<IWaypoint> = []; waypoints: Array<IWaypoint> = [];
lockMapClicks: (status: boolean) => void; lockMapClicks: Props['lockMapClicks'];
setRouterPoints: (count: void) => void; setRouterPoints: Props['setRouterPoints'];
pushPolyPoints: (coordinates: Array<{ lat: number, lng: number }>) => void; pushPolyPoints: Props['pushPolyPoints'];
router: Routing; router: Routing;
} }

View file

@ -9,6 +9,7 @@ import classnames from 'classnames';
import { getLabelDirection } from '$utils/geom'; import { getLabelDirection } from '$utils/geom';
import { ILatLng } from "$modules/Stickers"; import { ILatLng } from "$modules/Stickers";
import { IRootState } from "$redux/user/reducer"; import { IRootState } from "$redux/user/reducer";
import { editor } from "$modules/Editor";
const getX = e => ( const getX = e => (
e.touches && e.touches.length > 0 e.touches && e.touches.length > 0
@ -25,34 +26,18 @@ export interface IStickerDump {
text?: string, 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 { interface Props {
latlng: ILatLng; latlng: ILatLng;
deleteSticker: (sticker: this) => void;
map: Map; map: Map;
lockMapClicks: (status: boolean) => void;
sticker: IRootState['activeSticker']['sticker']; sticker: IRootState['activeSticker']['sticker'];
set: IRootState['activeSticker']['set']; set: IRootState['activeSticker']['set'];
triggerOnChange: () => void;
angle?: number; angle?: number;
text?: string; text?: string;
deleteSticker: (sticker: this) => void;
triggerOnChange: typeof editor.triggerOnChange;
lockMapClicks: typeof editor.lockMapClicks;
} }
export class Sticker { export class Sticker {

View file

@ -2,7 +2,7 @@ import { LayerGroup, layerGroup, Map } from 'leaflet';
import { IStickerDump, Sticker } from '$modules/Sticker'; import { IStickerDump, Sticker } from '$modules/Sticker';
import { MarkerClusterGroup } from 'leaflet.markercluster/dist/leaflet.markercluster-src.js'; import { MarkerClusterGroup } from 'leaflet.markercluster/dist/leaflet.markercluster-src.js';
import { clusterIcon } from '$utils/clusterIcon'; import { clusterIcon } from '$utils/clusterIcon';
import { Editor } from "$modules/Editor"; import { editor, Editor } from "$modules/Editor";
export interface ILatLng { export interface ILatLng {
lat: number, lat: number,
@ -12,8 +12,9 @@ export interface ILatLng {
interface Props { interface Props {
editor: Editor; editor: Editor;
map: Map; map: Map;
triggerOnChange: () => void;
lockMapClicks: (x: boolean) => void; triggerOnChange: typeof editor.triggerOnChange;
lockMapClicks: typeof editor.lockMapClicks;
} }
export class Stickers { export class Stickers {