Browse Source

refactor: move overlayType to map

master
Cmen 3 years ago
parent
commit
1ca28f82b2
  1. 3
      src/editor/Catalog/index.tsx
  2. 3
      src/editor/Plot/Tools/index.tsx
  3. 4
      src/editor/Property/index.tsx
  4. 5
      src/map/MapEditor.ts
  5. 3
      src/map/editors/BaseOverlayEditor.ts
  6. 3
      src/map/editors/CircleEditor.ts
  7. 3
      src/map/editors/PolygonEditor.ts
  8. 3
      src/map/editors/PolylineEditor.ts
  9. 3
      src/map/editors/RectangleEditor.ts
  10. 9
      src/map/type.ts
  11. 3
      src/store/actions/StoreAction.ts
  12. 4
      src/store/actions/index.ts
  13. 2
      src/store/constants.ts
  14. 4
      src/store/reducers/map/index.ts
  15. 3
      src/store/utils/getGeoJSON.ts
  16. 3
      src/store/utils/getMapOptions.ts
  17. 7
      src/types/enum.ts
  18. 2
      src/utils/index.ts

3
src/editor/Catalog/index.tsx

@ -2,11 +2,10 @@ import { Collapse } from "antd";
import { useSelector } from "react-redux";
import { editorAction, selectedIdsSelector, mapOptionsSelector } from "@store";
import { IOverlay } from "@map";
import { IOverlay, OverlayTypes } from "@map";
import "./style.less";
import classNames from "classnames";
import { OverlayTypes } from "../../types/enum";
const { Panel } = Collapse;

3
src/editor/Plot/Tools/index.tsx

@ -7,7 +7,8 @@ import {
statusSelector,
overlayTypeSelector,
} from "@store";
import { OverlayTypes, Status } from "@types";
import { Status } from "@types";
import { OverlayTypes } from "@map";
import { SearchModal } from "./SearchModal";
import { useState } from "react";

4
src/editor/Property/index.tsx

@ -1,9 +1,7 @@
import { useSelector } from "react-redux";
import { Form, Select } from "antd";
import { selectedIdsSelector, mapOptionsSelector, editorAction } from "@store";
import { OverlayCategory, IOverlay } from "@map";
import { OverlayTypes } from "@types";
import { OverlayCategory, IOverlay, OverlayTypes } from "@map";
import { FineInput } from "./FineInput";
import { OverlayBackground } from "./OverlayBackground";

5
src/map/MapEditor.ts

@ -2,6 +2,7 @@ import Emitter from "@finevis/emitter";
import "@amap/amap-jsapi-types";
import { getOverlayPaths, getUID, registerHotkey } from "@utils";
import { EventTypes } from "@types";
import {
BaseOverlayEditor,
@ -11,12 +12,10 @@ import {
CircleEditor,
} from "./editors";
import { IMapOptions, IMapEditor, IOverlay } from "./type";
import { IMapOptions, IMapEditor, IOverlay, OverlayTypes } from "./type";
import { PolygonOptions, PolylineOptions, SelectedOptions } from "./constants";
import { EventTypes, OverlayTypes } from "../types/enum";
type AMapOverlayEditor =
| AMap.RectangleEditor
| AMap.PolygonEditor

3
src/map/editors/BaseOverlayEditor.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IOverlay } from "../type";
import { IOverlay, OverlayTypes } from "../type";
export abstract class BaseOverlayEditor<T extends AMap.BaseEditor> {
map: AMap.Map;

3
src/map/editors/CircleEditor.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IOverlay } from "../type";
import { IOverlay, OverlayTypes } from "../type";
import { BaseOverlayEditor } from "./BaseOverlayEditor";
export class CircleEditor extends BaseOverlayEditor<AMap.CircleEditor> {

3
src/map/editors/PolygonEditor.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IOverlay } from "../type";
import { IOverlay, OverlayTypes } from "../type";
import { BaseOverlayEditor } from "./BaseOverlayEditor";
export class PolygonEditor extends BaseOverlayEditor<AMap.PolygonEditor> {

3
src/map/editors/PolylineEditor.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IOverlay } from "../type";
import { IOverlay, OverlayTypes } from "../type";
import { BaseOverlayEditor } from "./BaseOverlayEditor";
export class PolylineEditor extends BaseOverlayEditor<AMap.PolylineEditor> {

3
src/map/editors/RectangleEditor.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IOverlay } from "../type";
import { IOverlay, OverlayTypes } from "../type";
import { BaseOverlayEditor } from "./BaseOverlayEditor";
export class RectangleEditor extends BaseOverlayEditor<AMap.RectangleEditor> {

9
src/map/type.ts

@ -1,4 +1,4 @@
import { EventTypes, OverlayTypes } from "@types";
import { EventTypes } from "@types";
export interface IMapEditor {
on(type: EventTypes, evt: any): void;
@ -40,3 +40,10 @@ export interface IMapOptions {
center?: GeoJSON.Position;
zoom?: number;
}
export enum OverlayTypes {
Rectangle = "rectangle",
Polygon = "polygon",
Polyline = "polyline",
Circle = "circle",
}

3
src/store/actions/StoreAction.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IOverlay } from "@map";
import { IOverlay, OverlayTypes } from "@map";
import { IEditorState } from "../type";
export enum ActionTypes {
CreateOverlay = "createOverlay",

4
src/store/actions/index.ts

@ -10,8 +10,8 @@ import {
} from "@utils";
import { getGeoJSON, getMapOptions } from "../utils";
import { OverlayTypes, EventTypes } from "@types";
import { IOverlay, IMapOptions } from "@map";
import { EventTypes } from "@types";
import { IOverlay, IMapOptions, OverlayTypes } from "@map";
import { StoreAction } from "./StoreAction";
import { IStore } from "../type";
import { initState } from "../initState";

2
src/store/constants.ts

@ -1,4 +1,4 @@
import { OverlayTypes } from "@types";
import { OverlayTypes } from "@map";
export const OverlayNamePrefixs: Record<OverlayTypes, string> = {
[OverlayTypes.Rectangle]: "矩形",

4
src/store/reducers/map/index.ts

@ -1,8 +1,8 @@
import produce from "immer";
import { initState } from "../../initState";
import { OverlayNamePrefixs } from "@store";
import { OverlayTypes, Status } from "@types";
import { IOverlay, OverlayCategory } from "@map";
import { Status } from "@types";
import { IOverlay, OverlayCategory, OverlayTypes } from "@map";
export function createOverlay(state = initState, payload: OverlayTypes) {
return produce(state, (draft) => {

3
src/store/utils/getGeoJSON.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types";
import { IMapOptions, IOverlay, OverlayCategory } from "@map";
import { IMapOptions, IOverlay, OverlayCategory, OverlayTypes } from "@map";
import { gcj02_To_gps84 } from "@utils";
import * as turf from "@turf/turf";

3
src/store/utils/getMapOptions.ts

@ -1,5 +1,4 @@
import { IMapOptions, IOverlay, OverlayCategory } from "@map";
import { OverlayTypes } from "@types";
import { IMapOptions, IOverlay, OverlayCategory, OverlayTypes } from "@map";
import { getUID, gps84_To_gcj02 } from "@utils";
export function getMapOptions(geojson: GeoJSON.FeatureCollection) {

7
src/types/enum.ts

@ -2,13 +2,6 @@ export enum EventTypes {
FinishEditOverlay = "finishEditOverlay",
}
export enum OverlayTypes {
Rectangle = "rectangle",
Polygon = "polygon",
Polyline = "polyline",
Circle = "circle",
}
// 操作指令集
export enum Command {
CreateOverlay = "createOveraly",

2
src/utils/index.ts

@ -1,5 +1,5 @@
import { uid } from "uid";
import { OverlayTypes } from "@types";
import { OverlayTypes } from "@map";
export * from "./hotkeys";
export * from "./download";

Loading…
Cancel
Save