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 { 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<IWaypoint>;
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<IWaypoint> = [];
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;
}

View file

@ -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 {

View file

@ -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 {