Cmen
3 years ago
18 changed files with 4786 additions and 4604 deletions
@ -0,0 +1,15 @@
|
||||
export abstract class BaseLayerEditor<T extends AMap.BaseEditor> { |
||||
map: AMap.Map; |
||||
editor: T; |
||||
constructor(map: AMap.Map) { |
||||
this.map = map; |
||||
this.editor = this.initEditor(map); |
||||
} |
||||
|
||||
abstract initEditor(map: AMap.Map): T; |
||||
|
||||
create() { |
||||
this.editor.setTarget(null); |
||||
this.editor.open(); |
||||
} |
||||
} |
@ -0,0 +1,7 @@
|
||||
import { BaseLayerEditor } from "./BaseLayerEditor"; |
||||
|
||||
export class RectangleEditor extends BaseLayerEditor<AMap.PolygonEditor> { |
||||
initEditor(map: AMap.Map) { |
||||
return new AMap.RectangleEditor(this.map); |
||||
} |
||||
} |
@ -0,0 +1,2 @@
|
||||
export * from "./BaseLayerEditor"; |
||||
export * from "./RectangleEditor"; |
@ -0,0 +1,18 @@
|
||||
export enum ActionTypes { |
||||
AddRect = "addRect", |
||||
CreateOverlay = "createOverlay", |
||||
} |
||||
|
||||
export class EditorAction { |
||||
addRect() { |
||||
return { |
||||
type: ActionTypes.AddRect, |
||||
}; |
||||
} |
||||
createOverlay(type: string) { |
||||
return { |
||||
type: ActionTypes.CreateOverlay, |
||||
payload: type, |
||||
}; |
||||
} |
||||
} |
@ -1,11 +1,27 @@
|
||||
import { createStore } from "redux"; |
||||
import { initState } from "./initState"; |
||||
import { ActionTypes } from "./actions"; |
||||
import { IEditorState } from "./type"; |
||||
|
||||
export type Action = { |
||||
type: string; |
||||
payload: any; |
||||
type: ActionTypes; |
||||
payload?: any; |
||||
}; |
||||
|
||||
export function reducer(state = initState, action: Action) { |
||||
return state; |
||||
export function reducer(state = initState, action: Action): IEditorState { |
||||
const { type, payload } = action; |
||||
switch (type) { |
||||
case ActionTypes.CreateOverlay: |
||||
return { |
||||
...state, |
||||
map: { |
||||
...state.map, |
||||
status: "createOverlay", |
||||
overlayType: payload as string, |
||||
}, |
||||
//
|
||||
}; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
||||
|
@ -1,6 +0,0 @@
|
||||
declare global { |
||||
namespace AMapLoader { |
||||
const load: (config: any) => Promise<AMap.Map>; |
||||
} |
||||
} |
||||
export {}; |
@ -0,0 +1,22 @@
|
||||
declare global { |
||||
namespace AMapLoader { |
||||
const load: (config: any) => Promise<AMap.Map>; |
||||
} |
||||
namespace AMap { |
||||
interface IBaseEditor { |
||||
// new (map: AMap.Map): any;
|
||||
} |
||||
class BaseEditor implements IBaseEditor { |
||||
constructor(map: AMap.Map); |
||||
setTarget(target: any): void; |
||||
open(): void; |
||||
} |
||||
class PolygonEditor extends BaseEditor { |
||||
//
|
||||
} |
||||
class RectangleEditor extends BaseEditor { |
||||
//
|
||||
} |
||||
} |
||||
} |
||||
export {}; |
Loading…
Reference in new issue