deeptwins-engine-3d 0.1.63 → 0.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/Build/DeepTwins/Workers/MvtVector.worker.js +1 -0
- package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
- package/dist/esm/drawer/common.d.ts +61 -0
- package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
- package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +1 -1
- package/dist/esm/drawer/index.d.ts +11 -18
- package/dist/esm/drawer/index.js +329 -80
- package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
- package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
- package/dist/esm/drawer/shape/Assemble.js +415 -0
- package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/AttackArrow.js +442 -0
- package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
- package/dist/esm/drawer/shape/BaseShape.js +175 -20
- package/dist/esm/drawer/shape/Bow.d.ts +31 -0
- package/dist/esm/drawer/shape/Bow.js +375 -0
- package/dist/esm/drawer/shape/Circle.d.ts +37 -0
- package/dist/esm/drawer/shape/Circle.js +461 -0
- package/dist/esm/drawer/shape/Curve.d.ts +29 -0
- package/dist/esm/drawer/shape/Curve.js +386 -0
- package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
- package/dist/esm/drawer/shape/DragPoint.js +211 -0
- package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
- package/dist/esm/drawer/shape/Elliptic.js +491 -0
- package/dist/esm/drawer/shape/Formation.d.ts +33 -0
- package/dist/esm/drawer/shape/Formation.js +395 -0
- package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/PincerArrow.js +445 -0
- package/dist/esm/drawer/shape/Point.d.ts +2 -31
- package/dist/esm/drawer/shape/Point.js +7 -201
- package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
- package/dist/esm/drawer/shape/Polygon.js +10 -81
- package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
- package/dist/esm/drawer/shape/Polyline.js +10 -81
- package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
- package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
- package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
- package/dist/esm/drawer/shape/Sector.d.ts +37 -0
- package/dist/esm/drawer/shape/Sector.js +568 -0
- package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/StraightArrow.js +422 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
- package/dist/esm/drawer/types.d.ts +23 -0
- package/dist/esm/drawer/types.js +11 -0
- package/dist/esm/drawer/utils.d.ts +14 -0
- package/dist/esm/drawer/utils.js +320 -2
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -3
- package/dist/esm/measure/Area.d.ts +17 -17
- package/dist/esm/measure/Area.js +95 -63
- package/dist/esm/measure/BaseDraw.d.ts +9 -4
- package/dist/esm/measure/BaseDraw.js +37 -2
- package/dist/esm/measure/Distance.d.ts +9 -9
- package/dist/esm/measure/Distance.js +52 -68
- package/dist/esm/measure/index.d.ts +16 -26
- package/dist/esm/measure/index.js +72 -84
- package/dist/esm/measure/types.d.ts +94 -0
- package/dist/esm/measure/types.js +17 -0
- package/dist/esm/measure/utils.d.ts +7 -7
- package/dist/esm/measure/utils.js +43 -24
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +241 -0
- package/dist/esm/tileLayer/MvtVectorLoad.js +1353 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.d.ts +25 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.js +126 -0
- package/dist/esm/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +2 -1
- package/dist/assets/Build/DeepTwins/Image/compass/pointer-white.png +0 -0
- package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
- package/dist/esm/plot/create/CreateAssemble.js +0 -63
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
- package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
- package/dist/esm/plot/create/CreateBillboard.js +0 -47
- package/dist/esm/plot/create/CreateBow.d.ts +0 -2
- package/dist/esm/plot/create/CreateBow.js +0 -63
- package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
- package/dist/esm/plot/create/CreateCircle.js +0 -68
- package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
- package/dist/esm/plot/create/CreateCurve.js +0 -76
- package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
- package/dist/esm/plot/create/CreateElliptic.js +0 -69
- package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
- package/dist/esm/plot/create/CreateFlag.js +0 -80
- package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
- package/dist/esm/plot/create/CreateFormation.js +0 -65
- package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreeLine.js +0 -69
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
- package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
- package/dist/esm/plot/create/CreateLabel.js +0 -55
- package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
- package/dist/esm/plot/create/CreateLineArrow.js +0 -79
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
- package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
- package/dist/esm/plot/create/CreatePoint.js +0 -47
- package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolygon.js +0 -80
- package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolyline.js +0 -70
- package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRectangle.js +0 -60
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
- package/dist/esm/plot/create/CreateSector.d.ts +0 -2
- package/dist/esm/plot/create/CreateSector.js +0 -65
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
- package/dist/esm/plot/create/index.d.ts +0 -25
- package/dist/esm/plot/create/index.js +0 -25
- package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
- package/dist/esm/plot/edit/EditAssemble.js +0 -120
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
- package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
- package/dist/esm/plot/edit/EditBillboard.js +0 -70
- package/dist/esm/plot/edit/EditBow.d.ts +0 -8
- package/dist/esm/plot/edit/EditBow.js +0 -119
- package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
- package/dist/esm/plot/edit/EditCircle.js +0 -133
- package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
- package/dist/esm/plot/edit/EditCurve.js +0 -180
- package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
- package/dist/esm/plot/edit/EditElliptic.js +0 -144
- package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
- package/dist/esm/plot/edit/EditFlag.js +0 -121
- package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
- package/dist/esm/plot/edit/EditFormation.js +0 -120
- package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
- package/dist/esm/plot/edit/EditLabel.js +0 -100
- package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditLineArrow.js +0 -180
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
- package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
- package/dist/esm/plot/edit/EditPoint.js +0 -70
- package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolygon.js +0 -181
- package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolyline.js +0 -179
- package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRectangle.js +0 -119
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
- package/dist/esm/plot/edit/EditSector.d.ts +0 -8
- package/dist/esm/plot/edit/EditSector.js +0 -120
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
- package/dist/esm/plot/edit/index.d.ts +0 -23
- package/dist/esm/plot/edit/index.js +0 -23
- package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
- package/dist/esm/plot/utils/DomUtil.js +0 -100
- package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
- package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
- package/dist/esm/plot/utils/ReminderTip.js +0 -67
- package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
- package/dist/esm/plot/utils/Tooltip.js +0 -97
- /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
options: any;
|
|
3
|
-
getMap: any;
|
|
4
|
-
setDrawerLayer: any;
|
|
5
|
-
_changeStatus: any;
|
|
6
|
-
_updateTooltip: any;
|
|
7
|
-
}
|
|
8
|
-
export declare const STATUS: {
|
|
9
|
-
readonly INIT: "INIT";
|
|
10
|
-
readonly START_DRAW: "START_DRAW";
|
|
11
|
-
readonly DRAWING: "DRAWING";
|
|
12
|
-
readonly END_DRAW: "END_DRAW";
|
|
13
|
-
readonly EDITING: "EDITING";
|
|
14
|
-
readonly END_EDIT: "END_EDIT";
|
|
15
|
-
};
|
|
16
|
-
export type Status = (typeof STATUS)[keyof typeof STATUS];
|
|
1
|
+
import type { DataTransformDrawOptions, DrawContext } from './types';
|
|
17
2
|
export declare const MULTI_POINT_SHAPE_TYPES: {
|
|
18
3
|
readonly POLYLINE: "polyline";
|
|
19
4
|
readonly POLYGON: "polygon";
|
|
5
|
+
readonly ATTACK_ARROW: "attackArrow";
|
|
6
|
+
readonly CURVE: "curve";
|
|
7
|
+
readonly PINCER_ARROW: "pincerArrow";
|
|
8
|
+
readonly SECTOR: "sector";
|
|
20
9
|
};
|
|
21
|
-
export declare const MULTI_POINT_SHAPES: ("polygon" | "
|
|
10
|
+
export declare const MULTI_POINT_SHAPES: ("polyline" | "polygon" | "attackArrow" | "curve" | "pincerArrow" | "sector")[];
|
|
22
11
|
declare class Drawer implements DrawContext {
|
|
23
12
|
private readonly _mapContext;
|
|
24
13
|
private readonly _drawContext;
|
|
@@ -36,6 +25,7 @@ declare class Drawer implements DrawContext {
|
|
|
36
25
|
private _instance;
|
|
37
26
|
private _drawLayers;
|
|
38
27
|
constructor(map: any, options?: any);
|
|
28
|
+
private _resetInteractionState;
|
|
39
29
|
private _canOperate;
|
|
40
30
|
getMap(): any;
|
|
41
31
|
_isDragPoint(e: any): any;
|
|
@@ -43,7 +33,8 @@ declare class Drawer implements DrawContext {
|
|
|
43
33
|
private _destroyListeners;
|
|
44
34
|
_updateTooltip(): void;
|
|
45
35
|
_changeStatus(status: any): void;
|
|
46
|
-
|
|
36
|
+
private _createRestoreLayer;
|
|
37
|
+
dataTransformDraw(data: any, options?: DataTransformDrawOptions): any[] | undefined;
|
|
47
38
|
startDraw(type: any, config?: any): any;
|
|
48
39
|
private _stopDraw;
|
|
49
40
|
startEdit(id: any): void;
|
|
@@ -57,3 +48,5 @@ declare class Drawer implements DrawContext {
|
|
|
57
48
|
destroy(): void;
|
|
58
49
|
}
|
|
59
50
|
export default Drawer;
|
|
51
|
+
export { STATUS } from './types';
|
|
52
|
+
export type { DataTransformDrawOptions, DrawContext, Status } from './types';
|
package/dist/esm/drawer/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
5
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
6
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -12,47 +14,71 @@ import { DEFAULT_DRAWER_OPTIONS, LAYER_EVENT_TYPE } from "../constant";
|
|
|
12
14
|
import BaseSource from "../graphicLayer/BaseSource";
|
|
13
15
|
import * as utils from "../tool/utils";
|
|
14
16
|
import ToolTip from "../toolTip/index";
|
|
17
|
+
import Assemble from "./shape/Assemble";
|
|
18
|
+
import AttackArrow from "./shape/AttackArrow";
|
|
19
|
+
import Bow from "./shape/Bow";
|
|
20
|
+
import Circle from "./shape/Circle";
|
|
21
|
+
import Curve from "./shape/Curve";
|
|
22
|
+
import Elliptic from "./shape/Elliptic";
|
|
23
|
+
import Formation from "./shape/Formation";
|
|
24
|
+
import PincerArrow from "./shape/PincerArrow";
|
|
15
25
|
import Point from "./shape/Point";
|
|
16
26
|
import Polygon from "./shape/Polygon";
|
|
17
27
|
import Polyline from "./shape/Polyline";
|
|
18
|
-
import
|
|
28
|
+
import RegularPolygon from "./shape/RegularPolygon";
|
|
29
|
+
import RightAngleArrow from "./shape/RightAngleArrow";
|
|
30
|
+
import Sector from "./shape/Sector";
|
|
31
|
+
import StraightArrow from "./shape/StraightArrow";
|
|
32
|
+
import SwallowtailArrow from "./shape/SwallowtailArrow";
|
|
33
|
+
import { STATUS } from "./types";
|
|
34
|
+
import { getDrawerRestoreItems, getSectorRestoreAnchors } from "./utils";
|
|
19
35
|
|
|
20
36
|
// 根据类型相应的实现类
|
|
21
37
|
var DYNAMIC_GRAPHICS_TYPE = {
|
|
22
38
|
point: Point,
|
|
23
39
|
polyline: Polyline,
|
|
24
|
-
polygon: Polygon
|
|
40
|
+
polygon: Polygon,
|
|
41
|
+
assemble: Assemble,
|
|
42
|
+
attackArrow: AttackArrow,
|
|
43
|
+
bow: Bow,
|
|
44
|
+
curve: Curve,
|
|
45
|
+
elliptic: Elliptic,
|
|
46
|
+
formation: Formation,
|
|
47
|
+
pincerArrow: PincerArrow,
|
|
48
|
+
rightAngleArrow: RightAngleArrow,
|
|
49
|
+
sector: Sector,
|
|
50
|
+
straightArrow: StraightArrow,
|
|
51
|
+
swallowtailArrow: SwallowtailArrow,
|
|
52
|
+
circle: Circle,
|
|
53
|
+
regularPolygon: RegularPolygon
|
|
25
54
|
};
|
|
26
55
|
|
|
27
|
-
// 根据相应的geoJson类型获取相应的实现类
|
|
28
|
-
var dynamicGraphicsGeoJsonType = {
|
|
29
|
-
Point: Point,
|
|
30
|
-
MultiPoint: Point,
|
|
31
|
-
LineString: Polyline,
|
|
32
|
-
MultiLineString: Polyline,
|
|
33
|
-
Polygon: Polygon,
|
|
34
|
-
MultiPolygon: Polygon
|
|
35
|
-
};
|
|
36
|
-
// 状态表定义
|
|
37
|
-
export var STATUS = {
|
|
38
|
-
INIT: 'INIT',
|
|
39
|
-
START_DRAW: 'START_DRAW',
|
|
40
|
-
DRAWING: 'DRAWING',
|
|
41
|
-
END_DRAW: 'END_DRAW',
|
|
42
|
-
EDITING: 'EDITING',
|
|
43
|
-
END_EDIT: 'END_EDIT'
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// 从状态表推导类型
|
|
47
|
-
|
|
48
56
|
// 支持多点绘制的形状类型表
|
|
49
57
|
export var MULTI_POINT_SHAPE_TYPES = {
|
|
50
58
|
POLYLINE: 'polyline',
|
|
51
|
-
POLYGON: 'polygon'
|
|
59
|
+
POLYGON: 'polygon',
|
|
60
|
+
ATTACK_ARROW: 'attackArrow',
|
|
61
|
+
CURVE: 'curve',
|
|
62
|
+
PINCER_ARROW: 'pincerArrow',
|
|
63
|
+
SECTOR: 'sector'
|
|
52
64
|
};
|
|
53
65
|
|
|
54
66
|
// 支持多点绘制的形状类型数组
|
|
55
67
|
export var MULTI_POINT_SHAPES = Object.values(MULTI_POINT_SHAPE_TYPES);
|
|
68
|
+
|
|
69
|
+
// 通过两个控制点完成绘制的形状类型。
|
|
70
|
+
var TWO_POINT_SHAPE_TYPES = {
|
|
71
|
+
CIRCLE: 'circle',
|
|
72
|
+
REGULAR_POLYGON: 'regularPolygon',
|
|
73
|
+
ASSEMBLE: 'assemble',
|
|
74
|
+
BOW: 'bow',
|
|
75
|
+
ELLIPTIC: 'elliptic',
|
|
76
|
+
FORMATION: 'formation',
|
|
77
|
+
RIGHT_ANGLE_ARROW: 'rightAngleArrow',
|
|
78
|
+
STRAIGHT_ARROW: 'straightArrow',
|
|
79
|
+
SWALLOWTAIL_ARROW: 'swallowtailArrow'
|
|
80
|
+
};
|
|
81
|
+
var TWO_POINT_SHAPES = Object.values(TWO_POINT_SHAPE_TYPES);
|
|
56
82
|
var Drawer = /*#__PURE__*/function () {
|
|
57
83
|
function Drawer(map) {
|
|
58
84
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -89,9 +115,23 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
89
115
|
_updateTooltip: this._updateTooltip.bind(this)
|
|
90
116
|
};
|
|
91
117
|
}
|
|
92
|
-
|
|
93
|
-
// 是否能进行操作
|
|
94
118
|
_createClass(Drawer, [{
|
|
119
|
+
key: "_resetInteractionState",
|
|
120
|
+
value: function _resetInteractionState() {
|
|
121
|
+
this._dragging = false;
|
|
122
|
+
var map = this.getMap();
|
|
123
|
+
if (!map) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (typeof map.isDestroyed === 'function' && map.isDestroyed()) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
map.canvas.style.cursor = 'default';
|
|
130
|
+
map.scene.screenSpaceCameraController.enableRotate = true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 是否能进行操作
|
|
134
|
+
}, {
|
|
95
135
|
key: "_canOperate",
|
|
96
136
|
value: function _canOperate() {
|
|
97
137
|
if (this.isDestroyed) {
|
|
@@ -113,11 +153,11 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
113
153
|
var _this$_instance$dragP, _this$_instance$edges;
|
|
114
154
|
// 拖拽点图层
|
|
115
155
|
var dragPoint = (_this$_instance$dragP = this._instance.dragPoints) === null || _this$_instance$dragP === void 0 ? void 0 : _this$_instance$dragP.find(function (point) {
|
|
116
|
-
var _e$pickedObject;
|
|
117
|
-
return point.layer.layers[0].id === (e === null || e === void 0 || (_e$pickedObject = e.pickedObject) === null || _e$pickedObject === void 0 || (_e$pickedObject = _e$pickedObject.id) === null || _e$pickedObject === void 0 ? void 0 : _e$pickedObject.id);
|
|
156
|
+
var _point$layer, _e$pickedObject;
|
|
157
|
+
return ((_point$layer = point.layer) === null || _point$layer === void 0 || (_point$layer = _point$layer.layers) === null || _point$layer === void 0 || (_point$layer = _point$layer[0]) === null || _point$layer === void 0 ? void 0 : _point$layer.id) === (e === null || e === void 0 || (_e$pickedObject = e.pickedObject) === null || _e$pickedObject === void 0 || (_e$pickedObject = _e$pickedObject.id) === null || _e$pickedObject === void 0 ? void 0 : _e$pickedObject.id);
|
|
118
158
|
});
|
|
119
159
|
// 中间点图层
|
|
120
|
-
var middlePoint = (_this$_instance$edges = this._instance.edges.find(function (t) {
|
|
160
|
+
var middlePoint = (_this$_instance$edges = this._instance.edges) === null || _this$_instance$edges === void 0 || (_this$_instance$edges = _this$_instance$edges.find(function (t) {
|
|
121
161
|
var _t$middlePoint, _e$pickedObject2;
|
|
122
162
|
return (t === null || t === void 0 || (_t$middlePoint = t.middlePoint) === null || _t$middlePoint === void 0 || (_t$middlePoint = _t$middlePoint.layer) === null || _t$middlePoint === void 0 || (_t$middlePoint = _t$middlePoint.layers) === null || _t$middlePoint === void 0 || (_t$middlePoint = _t$middlePoint[0]) === null || _t$middlePoint === void 0 ? void 0 : _t$middlePoint.id) === (e === null || e === void 0 || (_e$pickedObject2 = e.pickedObject) === null || _e$pickedObject2 === void 0 || (_e$pickedObject2 = _e$pickedObject2.id) === null || _e$pickedObject2 === void 0 ? void 0 : _e$pickedObject2.id);
|
|
123
163
|
})) === null || _this$_instance$edges === void 0 ? void 0 : _this$_instance$edges.middlePoint;
|
|
@@ -145,9 +185,8 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
145
185
|
this._eventLeftUp = this.getMap().on(LAYER_EVENT_TYPE.LEFT_UP, function (e) {
|
|
146
186
|
if (!_this._instance) return;
|
|
147
187
|
if (_this._dragging) {
|
|
148
|
-
_this._dragging = false;
|
|
149
188
|
_this._instance.mouseDragEnd(e.position);
|
|
150
|
-
_this.
|
|
189
|
+
_this._resetInteractionState();
|
|
151
190
|
}
|
|
152
191
|
});
|
|
153
192
|
// 鼠标点击
|
|
@@ -162,7 +201,7 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
162
201
|
if (!_this._instance) return;
|
|
163
202
|
// 绘制
|
|
164
203
|
if (_this._status === STATUS.START_DRAW || _this._status === STATUS.DRAWING) {
|
|
165
|
-
if (MULTI_POINT_SHAPES.includes(_this._instance.type)) {
|
|
204
|
+
if (MULTI_POINT_SHAPES.includes(_this._instance.type) || TWO_POINT_SHAPES.includes(_this._instance.type)) {
|
|
166
205
|
_this._instance.updateTempPosition(e.position);
|
|
167
206
|
}
|
|
168
207
|
}
|
|
@@ -221,13 +260,17 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
221
260
|
value: function _updateTooltip() {
|
|
222
261
|
if (!this._canOperate()) return;
|
|
223
262
|
if (this._status === STATUS.START_DRAW) {
|
|
263
|
+
var _this$_instance;
|
|
264
|
+
var shapeType = (_this$_instance = this._instance) === null || _this$_instance === void 0 ? void 0 : _this$_instance.type;
|
|
224
265
|
this.tooltip.setOptions({
|
|
225
|
-
text: '点击开始绘制'
|
|
266
|
+
text: shapeType === 'circle' || shapeType === 'regularPolygon' || shapeType === 'elliptic' ? '点击确定中心点' : shapeType === 'assemble' || shapeType === 'bow' || shapeType === 'formation' || shapeType === 'rightAngleArrow' || shapeType === 'straightArrow' || shapeType === 'swallowtailArrow' ? '点击确定起点' : '点击开始绘制'
|
|
226
267
|
});
|
|
227
268
|
this.tooltip.show(true);
|
|
228
269
|
} else if (this._status === STATUS.DRAWING) {
|
|
270
|
+
var _this$_instance2;
|
|
271
|
+
var _shapeType = (_this$_instance2 = this._instance) === null || _this$_instance2 === void 0 ? void 0 : _this$_instance2.type;
|
|
229
272
|
this.tooltip.setOptions({
|
|
230
|
-
text: '左键添加点,右键移除点,双击结束绘制'
|
|
273
|
+
text: _shapeType === 'circle' || _shapeType === 'regularPolygon' ? '移动鼠标调整半径,左键完成绘制' : _shapeType === 'elliptic' ? '移动鼠标调整长轴,左键完成绘制' : _shapeType === 'assemble' ? '移动鼠标调整集结地形状,左键完成绘制' : _shapeType === 'bow' ? '移动鼠标调整弓形,左键完成绘制' : _shapeType === 'formation' ? '移动鼠标调整阵型,左键完成绘制' : _shapeType === 'rightAngleArrow' ? '移动鼠标调整直角箭头,左键完成绘制' : _shapeType === 'straightArrow' ? '移动鼠标调整直线箭头,左键完成绘制' : _shapeType === 'swallowtailArrow' ? '移动鼠标调整燕尾箭头,左键完成绘制' : '左键添加点,右键移除点,双击结束绘制'
|
|
231
274
|
});
|
|
232
275
|
} else {
|
|
233
276
|
this.tooltip.show(false);
|
|
@@ -240,12 +283,176 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
240
283
|
value: function _changeStatus(status) {
|
|
241
284
|
this._status = status;
|
|
242
285
|
}
|
|
286
|
+
}, {
|
|
287
|
+
key: "_createRestoreLayer",
|
|
288
|
+
value: function _createRestoreLayer(shapeType, positions) {
|
|
289
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
290
|
+
var restoreConfig = config;
|
|
291
|
+
if (shapeType === 'circle') {
|
|
292
|
+
var hasCenter = Array.isArray(config === null || config === void 0 ? void 0 : config.center) && config.center.length >= 2;
|
|
293
|
+
if (!hasCenter) {
|
|
294
|
+
utils.warn('还原circle时必须显式传入center,当前已回退为普通polygon');
|
|
295
|
+
var _fallbackLayer = new Polygon(this._drawContext, config);
|
|
296
|
+
_fallbackLayer.transformData(positions);
|
|
297
|
+
return _fallbackLayer;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (shapeType === 'regularPolygon') {
|
|
301
|
+
var restoreSides = Number(config === null || config === void 0 ? void 0 : config.sides);
|
|
302
|
+
var _hasCenter = Array.isArray(config === null || config === void 0 ? void 0 : config.center) && config.center.length >= 2;
|
|
303
|
+
if (!_hasCenter || !Number.isFinite(restoreSides)) {
|
|
304
|
+
utils.warn('还原regularPolygon时必须显式传入center和sides,当前已回退为普通polygon');
|
|
305
|
+
var _fallbackLayer2 = new Polygon(this._drawContext, config);
|
|
306
|
+
_fallbackLayer2.transformData(positions);
|
|
307
|
+
return _fallbackLayer2;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (shapeType === 'assemble') {
|
|
311
|
+
var anchors = config === null || config === void 0 ? void 0 : config.anchors;
|
|
312
|
+
var hasAnchors = Array.isArray(anchors) && anchors.length >= 2 && anchors[0] && anchors[1];
|
|
313
|
+
if (!hasAnchors) {
|
|
314
|
+
utils.warn('还原assemble时必须显式传入anchors(>=2),当前已回退为普通polygon');
|
|
315
|
+
var _fallbackLayer3 = new Polygon(this._drawContext, config);
|
|
316
|
+
_fallbackLayer3.transformData(positions);
|
|
317
|
+
return _fallbackLayer3;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (shapeType === 'attackArrow') {
|
|
321
|
+
var _anchors = config === null || config === void 0 ? void 0 : config.anchors;
|
|
322
|
+
var _hasAnchors = Array.isArray(_anchors) && _anchors.length >= 3;
|
|
323
|
+
if (!_hasAnchors) {
|
|
324
|
+
utils.warn('还原attackArrow时必须显式传入anchors(>=3),当前已回退为普通polygon');
|
|
325
|
+
var _fallbackLayer4 = new Polygon(this._drawContext, config);
|
|
326
|
+
_fallbackLayer4.transformData(positions);
|
|
327
|
+
return _fallbackLayer4;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (shapeType === 'pincerArrow') {
|
|
331
|
+
var _anchors2 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
332
|
+
var _hasAnchors2 = Array.isArray(_anchors2) && _anchors2.length >= 3;
|
|
333
|
+
if (!_hasAnchors2) {
|
|
334
|
+
utils.warn('还原pincerArrow时必须显式传入anchors(>=3),当前已回退为普通polygon');
|
|
335
|
+
var _fallbackLayer5 = new Polygon(this._drawContext, config);
|
|
336
|
+
_fallbackLayer5.transformData(positions);
|
|
337
|
+
return _fallbackLayer5;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (shapeType === 'bow') {
|
|
341
|
+
var _anchors3 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
342
|
+
var _hasAnchors3 = Array.isArray(_anchors3) && _anchors3.length >= 2 && _anchors3[0] && _anchors3[1];
|
|
343
|
+
if (!_hasAnchors3) {
|
|
344
|
+
utils.warn('还原bow时必须显式传入anchors(>=2),当前已回退为普通polyline');
|
|
345
|
+
var _fallbackLayer6 = new Polyline(this._drawContext, config);
|
|
346
|
+
_fallbackLayer6.transformData(positions);
|
|
347
|
+
return _fallbackLayer6;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (shapeType === 'curve') {
|
|
351
|
+
var _anchors4 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
352
|
+
var _hasAnchors4 = Array.isArray(_anchors4) && _anchors4.length >= 2;
|
|
353
|
+
if (!_hasAnchors4) {
|
|
354
|
+
utils.warn('还原curve时必须显式传入anchors(>=2),当前已回退为普通polyline');
|
|
355
|
+
var _fallbackLayer7 = new Polyline(this._drawContext, config);
|
|
356
|
+
_fallbackLayer7.transformData(positions);
|
|
357
|
+
return _fallbackLayer7;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (shapeType === 'elliptic') {
|
|
361
|
+
var _anchors5 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
362
|
+
var _hasAnchors5 = Array.isArray(_anchors5) && _anchors5.length >= 2;
|
|
363
|
+
if (!_hasAnchors5) {
|
|
364
|
+
utils.warn('还原elliptic时必须显式传入anchors(>=2),当前已回退为普通polygon');
|
|
365
|
+
var _fallbackLayer8 = new Polygon(this._drawContext, config);
|
|
366
|
+
_fallbackLayer8.transformData(positions);
|
|
367
|
+
return _fallbackLayer8;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (shapeType === 'rightAngleArrow') {
|
|
371
|
+
var _anchors6 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
372
|
+
var _hasAnchors6 = Array.isArray(_anchors6) && _anchors6.length >= 2 && _anchors6[0] && _anchors6[1];
|
|
373
|
+
if (!_hasAnchors6) {
|
|
374
|
+
utils.warn('还原rightAngleArrow时必须显式传入anchors(>=2),当前已回退为普通polygon');
|
|
375
|
+
var _fallbackLayer9 = new Polygon(this._drawContext, config);
|
|
376
|
+
_fallbackLayer9.transformData(positions);
|
|
377
|
+
return _fallbackLayer9;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (shapeType === 'sector') {
|
|
381
|
+
var _restoreConfig;
|
|
382
|
+
var _anchors7 = (_restoreConfig = restoreConfig) === null || _restoreConfig === void 0 ? void 0 : _restoreConfig.anchors;
|
|
383
|
+
var _hasAnchors7 = Array.isArray(_anchors7) && _anchors7.length >= 3;
|
|
384
|
+
if (!_hasAnchors7) {
|
|
385
|
+
var inferredAnchors = getSectorRestoreAnchors(positions);
|
|
386
|
+
if (inferredAnchors) {
|
|
387
|
+
restoreConfig = _objectSpread(_objectSpread({}, restoreConfig), {}, {
|
|
388
|
+
anchors: inferredAnchors
|
|
389
|
+
});
|
|
390
|
+
} else {
|
|
391
|
+
utils.warn('还原sector时无法从已有 polygon 自动推导 anchors(>=3),当前已回退为普通polygon');
|
|
392
|
+
var _fallbackLayer10 = new Polygon(this._drawContext, restoreConfig);
|
|
393
|
+
_fallbackLayer10.transformData(positions);
|
|
394
|
+
return _fallbackLayer10;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (shapeType === 'straightArrow') {
|
|
399
|
+
var _anchors8 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
400
|
+
var _hasAnchors8 = Array.isArray(_anchors8) && _anchors8.length >= 2 && _anchors8[0] && _anchors8[1];
|
|
401
|
+
if (!_hasAnchors8) {
|
|
402
|
+
utils.warn('还原straightArrow时必须显式传入anchors(>=2),当前已回退为普通polygon');
|
|
403
|
+
var _fallbackLayer11 = new Polygon(this._drawContext, config);
|
|
404
|
+
_fallbackLayer11.transformData(positions);
|
|
405
|
+
return _fallbackLayer11;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (shapeType === 'swallowtailArrow') {
|
|
409
|
+
var _anchors9 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
410
|
+
var _hasAnchors9 = Array.isArray(_anchors9) && _anchors9.length >= 2 && _anchors9[0] && _anchors9[1];
|
|
411
|
+
if (!_hasAnchors9) {
|
|
412
|
+
utils.warn('还原swallowtailArrow时必须显式传入anchors(>=2),当前已回退为普通polygon');
|
|
413
|
+
var _fallbackLayer12 = new Polygon(this._drawContext, config);
|
|
414
|
+
_fallbackLayer12.transformData(positions);
|
|
415
|
+
return _fallbackLayer12;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (shapeType === 'formation') {
|
|
419
|
+
var _anchors10 = config === null || config === void 0 ? void 0 : config.anchors;
|
|
420
|
+
var _hasAnchors10 = Array.isArray(_anchors10) && _anchors10.length >= 2;
|
|
421
|
+
if (!_hasAnchors10) {
|
|
422
|
+
utils.warn('还原formation时必须显式传入anchors(>=2),当前已回退为普通polyline');
|
|
423
|
+
var _fallbackLayer13 = new Polyline(this._drawContext, config);
|
|
424
|
+
_fallbackLayer13.transformData(positions);
|
|
425
|
+
return _fallbackLayer13;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
var shapeClass = DYNAMIC_GRAPHICS_TYPE[shapeType];
|
|
429
|
+
if (!shapeClass) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
var layer = new shapeClass(this._drawContext, restoreConfig);
|
|
433
|
+
var transformResult = layer.transformData(positions, restoreConfig);
|
|
434
|
+
if (transformResult !== false) {
|
|
435
|
+
return layer;
|
|
436
|
+
}
|
|
437
|
+
if (shapeType !== 'circle' && shapeType !== 'regularPolygon' && shapeType !== 'assemble' && shapeType !== 'attackArrow' && shapeType !== 'bow' && shapeType !== 'curve' && shapeType !== 'elliptic' && shapeType !== 'pincerArrow' && shapeType !== 'rightAngleArrow' && shapeType !== 'sector' && shapeType !== 'straightArrow' && shapeType !== 'swallowtailArrow' && shapeType !== 'formation') {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (shapeType === 'bow' || shapeType === 'curve' || shapeType === 'formation') {
|
|
441
|
+
var _fallbackLayer14 = new Polyline(this._drawContext, restoreConfig);
|
|
442
|
+
_fallbackLayer14.transformData(positions);
|
|
443
|
+
return _fallbackLayer14;
|
|
444
|
+
}
|
|
445
|
+
var fallbackLayer = new Polygon(this._drawContext, restoreConfig);
|
|
446
|
+
fallbackLayer.transformData(positions);
|
|
447
|
+
return fallbackLayer;
|
|
448
|
+
}
|
|
243
449
|
|
|
244
450
|
// 转化为绘制类型
|
|
245
451
|
}, {
|
|
246
452
|
key: "dataTransformDraw",
|
|
247
453
|
value: function dataTransformDraw(data) {
|
|
248
454
|
var _this2 = this;
|
|
455
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
249
456
|
var dataType = BaseSource.analysisSourceType(data);
|
|
250
457
|
var transformGeoJson;
|
|
251
458
|
if (dataType === 'wkt') {
|
|
@@ -256,24 +463,11 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
256
463
|
if (!transformGeoJson) return;
|
|
257
464
|
var layers = [];
|
|
258
465
|
featureEach(transformGeoJson, function (feature) {
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (handleFeature.type === 'single') {
|
|
265
|
-
var layer = new shapeClass(_this2._drawContext);
|
|
266
|
-
layer.transformData(handleFeature.positions);
|
|
267
|
-
layers.push(layer);
|
|
268
|
-
}
|
|
269
|
-
if (handleFeature.type === 'multi') {
|
|
270
|
-
handleFeature.positions.forEach(function (position) {
|
|
271
|
-
var layer = new shapeClass(_this2._drawContext);
|
|
272
|
-
layer.transformData(position);
|
|
273
|
-
layers.push(layer);
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
466
|
+
var restoreItems = getDrawerRestoreItems(feature, options);
|
|
467
|
+
restoreItems.forEach(function (item) {
|
|
468
|
+
var layer = _this2._createRestoreLayer(item.shapeType, item.positions, item.config);
|
|
469
|
+
layer && layers.push(layer);
|
|
470
|
+
});
|
|
277
471
|
});
|
|
278
472
|
return layers;
|
|
279
473
|
}
|
|
@@ -284,14 +478,14 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
284
478
|
value: function startDraw(type) {
|
|
285
479
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
286
480
|
if (!this._canOperate()) return;
|
|
481
|
+
var shapeClass = DYNAMIC_GRAPHICS_TYPE[type];
|
|
482
|
+
if (!shapeClass) return;
|
|
287
483
|
if (this._instance) {
|
|
288
484
|
this._stopDraw();
|
|
289
485
|
}
|
|
290
486
|
this._changeStatus(STATUS.START_DRAW);
|
|
291
487
|
this.getMap().canvas.style.cursor = 'crosshair';
|
|
292
488
|
this._updateTooltip();
|
|
293
|
-
var shapeClass = DYNAMIC_GRAPHICS_TYPE[type];
|
|
294
|
-
if (!shapeClass) return;
|
|
295
489
|
this._instance = new shapeClass(this._drawContext, config);
|
|
296
490
|
return this._instance;
|
|
297
491
|
}
|
|
@@ -303,21 +497,28 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
303
497
|
if (!this._canOperate()) return;
|
|
304
498
|
if (!this._instance) return;
|
|
305
499
|
if (this._status === STATUS.INIT || this._status === STATUS.START_DRAW || this._status === STATUS.END_EDIT) {
|
|
306
|
-
var layer = this.
|
|
500
|
+
var layer = this._drawLayers.get(this._instance.id);
|
|
307
501
|
// layer未存入
|
|
308
502
|
if (!layer) {
|
|
309
503
|
this._instance.destroy();
|
|
310
504
|
}
|
|
505
|
+
this._resetInteractionState();
|
|
506
|
+
this._changeStatus(STATUS.INIT);
|
|
507
|
+
this._updateTooltip();
|
|
311
508
|
this._instance = null;
|
|
312
509
|
return;
|
|
313
510
|
}
|
|
314
511
|
if (this._status === STATUS.DRAWING) {
|
|
315
512
|
this.removeDrawerLayer(this._instance);
|
|
316
|
-
this._instance = null;
|
|
317
513
|
return;
|
|
318
514
|
}
|
|
319
515
|
if (this._status === STATUS.END_DRAW || this._status === STATUS.EDITING) {
|
|
320
|
-
this.
|
|
516
|
+
this._resetInteractionState();
|
|
517
|
+
this._instance.endEdit(this._instance, false);
|
|
518
|
+
this.setDrawerLayer(this._instance.id, this._instance);
|
|
519
|
+
this._instance = null;
|
|
520
|
+
this._changeStatus(STATUS.INIT);
|
|
521
|
+
this._updateTooltip();
|
|
321
522
|
return;
|
|
322
523
|
}
|
|
323
524
|
}
|
|
@@ -329,13 +530,20 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
329
530
|
if (!this._canOperate()) return;
|
|
330
531
|
if (!id) return;
|
|
331
532
|
if (this._instance) {
|
|
332
|
-
this.
|
|
333
|
-
|
|
334
|
-
|
|
533
|
+
if (this._status === STATUS.EDITING || this._status === STATUS.END_DRAW) {
|
|
534
|
+
this._resetInteractionState();
|
|
535
|
+
this._instance.endEdit(this._instance, false);
|
|
536
|
+
this.setDrawerLayer(this._instance.id, this._instance);
|
|
537
|
+
this._instance = null;
|
|
538
|
+
} else {
|
|
539
|
+
this._stopDraw();
|
|
540
|
+
}
|
|
335
541
|
}
|
|
542
|
+
var layer = this.getDrawerLayer(id);
|
|
543
|
+
if (!layer) return;
|
|
544
|
+
this._instance = layer;
|
|
336
545
|
this._changeStatus(STATUS.EDITING);
|
|
337
|
-
this.
|
|
338
|
-
if (!this._instance) return;
|
|
546
|
+
this._updateTooltip();
|
|
339
547
|
this._instance.startEdit();
|
|
340
548
|
}
|
|
341
549
|
|
|
@@ -344,7 +552,7 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
344
552
|
key: "endEdit",
|
|
345
553
|
value: function endEdit() {
|
|
346
554
|
if (!this._canOperate()) return;
|
|
347
|
-
this.
|
|
555
|
+
this._resetInteractionState();
|
|
348
556
|
this._changeStatus(STATUS.END_EDIT);
|
|
349
557
|
this._updateTooltip();
|
|
350
558
|
if (!this._instance) return;
|
|
@@ -357,16 +565,20 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
357
565
|
}, {
|
|
358
566
|
key: "getDrawerLayer",
|
|
359
567
|
value: function getDrawerLayer(id) {
|
|
360
|
-
if (!this._canOperate) return;
|
|
568
|
+
if (!this._canOperate()) return;
|
|
361
569
|
if (!id) return;
|
|
362
|
-
|
|
570
|
+
if (isString(id)) {
|
|
571
|
+
return this._drawLayers.get(id);
|
|
572
|
+
}
|
|
573
|
+
return id && _typeof(id) === 'object' && 'id' in id ? id : undefined;
|
|
363
574
|
}
|
|
364
575
|
|
|
365
576
|
// 添加完成绘制的图层
|
|
366
577
|
}, {
|
|
367
578
|
key: "setDrawerLayer",
|
|
368
579
|
value: function setDrawerLayer(id, value) {
|
|
369
|
-
if (!this.
|
|
580
|
+
if (!this._canOperate()) return;
|
|
581
|
+
if (!id || !value) return;
|
|
370
582
|
this._drawLayers.set(id, value);
|
|
371
583
|
}
|
|
372
584
|
|
|
@@ -374,14 +586,14 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
374
586
|
}, {
|
|
375
587
|
key: "removeDrawerLayer",
|
|
376
588
|
value: function removeDrawerLayer(id) {
|
|
377
|
-
if (!this._canOperate) return;
|
|
589
|
+
if (!this._canOperate()) return;
|
|
378
590
|
var layer = this.getDrawerLayer(id);
|
|
379
591
|
if (layer) {
|
|
380
|
-
var _this$
|
|
381
|
-
if (layer.id === (this === null || this === void 0 || (_this$
|
|
592
|
+
var _this$_instance3;
|
|
593
|
+
if (layer.id === (this === null || this === void 0 || (_this$_instance3 = this._instance) === null || _this$_instance3 === void 0 ? void 0 : _this$_instance3.id)) {
|
|
594
|
+
this._resetInteractionState();
|
|
382
595
|
this._instance = null;
|
|
383
|
-
this.
|
|
384
|
-
this.getMap().canvas.style.cursor = 'default';
|
|
596
|
+
this._changeStatus(STATUS.INIT);
|
|
385
597
|
this._updateTooltip();
|
|
386
598
|
}
|
|
387
599
|
this._drawLayers.delete(layer.id);
|
|
@@ -394,7 +606,7 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
394
606
|
}, {
|
|
395
607
|
key: "getAllDrawerLayers",
|
|
396
608
|
value: function getAllDrawerLayers() {
|
|
397
|
-
if (!this._canOperate) return;
|
|
609
|
+
if (!this._canOperate()) return;
|
|
398
610
|
return Array.from(this._drawLayers.values());
|
|
399
611
|
}
|
|
400
612
|
|
|
@@ -402,22 +614,36 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
402
614
|
}, {
|
|
403
615
|
key: "clearAllDrawerLayers",
|
|
404
616
|
value: function clearAllDrawerLayers() {
|
|
405
|
-
|
|
406
|
-
this.
|
|
617
|
+
var _this3 = this;
|
|
618
|
+
if (!this._canOperate()) return;
|
|
619
|
+
var layers = Array.from(new Set(this._drawLayers.values()));
|
|
620
|
+
this._drawLayers.clear();
|
|
621
|
+
layers.forEach(function (t) {
|
|
407
622
|
return t.destroy();
|
|
408
623
|
});
|
|
409
|
-
this.
|
|
624
|
+
if (this._instance && !layers.some(function (layer) {
|
|
625
|
+
return layer.id === _this3._instance.id;
|
|
626
|
+
})) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
this._resetInteractionState();
|
|
630
|
+
this._instance = null;
|
|
631
|
+
this._changeStatus(STATUS.INIT);
|
|
632
|
+
this._updateTooltip();
|
|
410
633
|
}
|
|
411
634
|
|
|
412
635
|
// 清除
|
|
413
636
|
}, {
|
|
414
637
|
key: "clear",
|
|
415
638
|
value: function clear() {
|
|
416
|
-
if (!this._canOperate) return;
|
|
417
|
-
this.
|
|
639
|
+
if (!this._canOperate()) return;
|
|
640
|
+
this._resetInteractionState();
|
|
418
641
|
this._changeStatus(STATUS.INIT);
|
|
419
642
|
this._updateTooltip();
|
|
420
|
-
|
|
643
|
+
if (this._instance) {
|
|
644
|
+
this._drawLayers.delete(this._instance.id);
|
|
645
|
+
this._instance.destroy();
|
|
646
|
+
}
|
|
421
647
|
this._instance = null;
|
|
422
648
|
this.clearAllDrawerLayers();
|
|
423
649
|
}
|
|
@@ -426,7 +652,7 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
426
652
|
}, {
|
|
427
653
|
key: "destroy",
|
|
428
654
|
value: function destroy() {
|
|
429
|
-
if (!this._canOperate) return;
|
|
655
|
+
if (!this._canOperate()) return;
|
|
430
656
|
this._destroyListeners();
|
|
431
657
|
this.clear();
|
|
432
658
|
this.tooltip.destroy();
|
|
@@ -436,4 +662,27 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
436
662
|
}]);
|
|
437
663
|
return Drawer;
|
|
438
664
|
}();
|
|
439
|
-
|
|
665
|
+
var getDrawerDrawingTooltipText = function getDrawerDrawingTooltipText(instance) {
|
|
666
|
+
if ((instance === null || instance === void 0 ? void 0 : instance.type) !== 'sector') {
|
|
667
|
+
return '左键添加点,右键移除点,双击结束绘制';
|
|
668
|
+
}
|
|
669
|
+
var anchorPositions = Array.isArray(instance === null || instance === void 0 ? void 0 : instance._anchorPositions) ? instance._anchorPositions : [];
|
|
670
|
+
return anchorPositions.length >= 2 ? '左键确定终止方向并结束绘制' : '左键确定半径';
|
|
671
|
+
};
|
|
672
|
+
Drawer.prototype._updateTooltip = function () {
|
|
673
|
+
if (!this._canOperate()) return;
|
|
674
|
+
if (this._status === STATUS.START_DRAW) {
|
|
675
|
+
this.tooltip.setOptions({
|
|
676
|
+
text: '点击开始绘制'
|
|
677
|
+
});
|
|
678
|
+
this.tooltip.show(true);
|
|
679
|
+
} else if (this._status === STATUS.DRAWING) {
|
|
680
|
+
this.tooltip.setOptions({
|
|
681
|
+
text: getDrawerDrawingTooltipText(this._instance)
|
|
682
|
+
});
|
|
683
|
+
} else {
|
|
684
|
+
this.tooltip.show(false);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
export default Drawer;
|
|
688
|
+
export { STATUS } from "./types";
|