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 { useSelector } from "react-redux";
import { editorAction, selectedIdsSelector, mapOptionsSelector } from "@store"; import { editorAction, selectedIdsSelector, mapOptionsSelector } from "@store";
import { IOverlay } from "@map"; import { IOverlay, OverlayTypes } from "@map";
import "./style.less"; import "./style.less";
import classNames from "classnames"; import classNames from "classnames";
import { OverlayTypes } from "../../types/enum";
const { Panel } = Collapse; const { Panel } = Collapse;

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

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

4
src/editor/Property/index.tsx

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

5
src/map/MapEditor.ts

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

3
src/map/editors/BaseOverlayEditor.ts

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

3
src/map/editors/CircleEditor.ts

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

3
src/map/editors/PolygonEditor.ts

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

3
src/map/editors/PolylineEditor.ts

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

3
src/map/editors/RectangleEditor.ts

@ -1,5 +1,4 @@
import { OverlayTypes } from "@types"; import { IOverlay, OverlayTypes } from "../type";
import { IOverlay } from "../type";
import { BaseOverlayEditor } from "./BaseOverlayEditor"; import { BaseOverlayEditor } from "./BaseOverlayEditor";
export class RectangleEditor extends BaseOverlayEditor<AMap.RectangleEditor> { 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 { export interface IMapEditor {
on(type: EventTypes, evt: any): void; on(type: EventTypes, evt: any): void;
@ -40,3 +40,10 @@ export interface IMapOptions {
center?: GeoJSON.Position; center?: GeoJSON.Position;
zoom?: number; 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, OverlayTypes } from "@map";
import { IOverlay } from "@map";
import { IEditorState } from "../type"; import { IEditorState } from "../type";
export enum ActionTypes { export enum ActionTypes {
CreateOverlay = "createOverlay", CreateOverlay = "createOverlay",

4
src/store/actions/index.ts

@ -10,8 +10,8 @@ import {
} from "@utils"; } from "@utils";
import { getGeoJSON, getMapOptions } from "../utils"; import { getGeoJSON, getMapOptions } from "../utils";
import { OverlayTypes, EventTypes } from "@types"; import { EventTypes } from "@types";
import { IOverlay, IMapOptions } from "@map"; import { IOverlay, IMapOptions, OverlayTypes } from "@map";
import { StoreAction } from "./StoreAction"; import { StoreAction } from "./StoreAction";
import { IStore } from "../type"; import { IStore } from "../type";
import { initState } from "../initState"; 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> = { export const OverlayNamePrefixs: Record<OverlayTypes, string> = {
[OverlayTypes.Rectangle]: "矩形", [OverlayTypes.Rectangle]: "矩形",

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

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

3
src/store/utils/getGeoJSON.ts

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

3
src/store/utils/getMapOptions.ts

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

7
src/types/enum.ts

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

2
src/utils/index.ts

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

Loading…
Cancel
Save