@antv/l7-component 2.25.6 → 2.25.7

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.
Files changed (151) hide show
  1. package/package.json +5 -5
  2. package/es/assets/iconfont/iconfont.d.ts +0 -21
  3. package/es/assets/iconfont/iconfont.js +0 -61
  4. package/es/constants/index.d.ts +0 -60
  5. package/es/constants/index.js +0 -60
  6. package/es/control/baseControl/buttonControl.d.ts +0 -60
  7. package/es/control/baseControl/buttonControl.js +0 -142
  8. package/es/control/baseControl/control.d.ts +0 -112
  9. package/es/control/baseControl/control.js +0 -256
  10. package/es/control/baseControl/index.d.ts +0 -4
  11. package/es/control/baseControl/index.js +0 -4
  12. package/es/control/baseControl/popperControl.d.ts +0 -28
  13. package/es/control/baseControl/popperControl.js +0 -92
  14. package/es/control/baseControl/selectControl.d.ts +0 -53
  15. package/es/control/baseControl/selectControl.js +0 -173
  16. package/es/control/exportImage.d.ts +0 -19
  17. package/es/control/exportImage.js +0 -73
  18. package/es/control/fullscreen.d.ts +0 -20
  19. package/es/control/fullscreen.js +0 -88
  20. package/es/control/geoLocate.d.ts +0 -17
  21. package/es/control/geoLocate.js +0 -60
  22. package/es/control/layerSwitch.d.ts +0 -27
  23. package/es/control/layerSwitch.js +0 -155
  24. package/es/control/logo.d.ts +0 -14
  25. package/es/control/logo.js +0 -49
  26. package/es/control/mapTheme.d.ts +0 -11
  27. package/es/control/mapTheme.js +0 -69
  28. package/es/control/mouseLocation.d.ts +0 -16
  29. package/es/control/mouseLocation.js +0 -52
  30. package/es/control/scale.d.ts +0 -35
  31. package/es/control/scale.js +0 -121
  32. package/es/control/swipe.d.ts +0 -66
  33. package/es/control/swipe.js +0 -392
  34. package/es/control/zoom.d.ts +0 -39
  35. package/es/control/zoom.js +0 -100
  36. package/es/css/button.less +0 -77
  37. package/es/css/control.less +0 -82
  38. package/es/css/index.css +0 -653
  39. package/es/css/index.less +0 -13
  40. package/es/css/l7.less +0 -69
  41. package/es/css/layerPopup.less +0 -9
  42. package/es/css/logo.less +0 -21
  43. package/es/css/mouseLocation.less +0 -9
  44. package/es/css/popper.less +0 -74
  45. package/es/css/popup.less +0 -176
  46. package/es/css/scale.less +0 -37
  47. package/es/css/select.less +0 -96
  48. package/es/css/swipe.less +0 -80
  49. package/es/css/variables.less +0 -29
  50. package/es/css/zoom.less +0 -34
  51. package/es/images/layers.png +0 -0
  52. package/es/images/layers.svg +0 -1
  53. package/es/images/logo.png +0 -0
  54. package/es/images/quanping.svg +0 -12
  55. package/es/index.d.ts +0 -19
  56. package/es/index.js +0 -708
  57. package/es/interface.d.ts +0 -29
  58. package/es/interface.js +0 -1
  59. package/es/marker-layer.d.ts +0 -46
  60. package/es/marker-layer.js +0 -509
  61. package/es/marker.d.ts +0 -66
  62. package/es/marker.js +0 -495
  63. package/es/popup/layerPopup.d.ts +0 -105
  64. package/es/popup/layerPopup.js +0 -341
  65. package/es/popup/popup.d.ts +0 -147
  66. package/es/popup/popup.js +0 -587
  67. package/es/utils/anchor.d.ts +0 -22
  68. package/es/utils/anchor.js +0 -31
  69. package/es/utils/eventManager.d.ts +0 -42
  70. package/es/utils/eventManager.js +0 -84
  71. package/es/utils/icon.d.ts +0 -1
  72. package/es/utils/icon.js +0 -12
  73. package/es/utils/popper.d.ts +0 -76
  74. package/es/utils/popper.js +0 -257
  75. package/es/utils/screenfull.d.ts +0 -2
  76. package/es/utils/screenfull.js +0 -106
  77. package/lib/assets/iconfont/iconfont.d.ts +0 -21
  78. package/lib/assets/iconfont/iconfont.js +0 -68
  79. package/lib/constants/index.d.ts +0 -60
  80. package/lib/constants/index.js +0 -66
  81. package/lib/control/baseControl/buttonControl.d.ts +0 -60
  82. package/lib/control/baseControl/buttonControl.js +0 -149
  83. package/lib/control/baseControl/control.d.ts +0 -112
  84. package/lib/control/baseControl/control.js +0 -269
  85. package/lib/control/baseControl/index.d.ts +0 -4
  86. package/lib/control/baseControl/index.js +0 -39
  87. package/lib/control/baseControl/popperControl.d.ts +0 -28
  88. package/lib/control/baseControl/popperControl.js +0 -99
  89. package/lib/control/baseControl/selectControl.d.ts +0 -53
  90. package/lib/control/baseControl/selectControl.js +0 -180
  91. package/lib/control/exportImage.d.ts +0 -19
  92. package/lib/control/exportImage.js +0 -80
  93. package/lib/control/fullscreen.d.ts +0 -20
  94. package/lib/control/fullscreen.js +0 -95
  95. package/lib/control/geoLocate.d.ts +0 -17
  96. package/lib/control/geoLocate.js +0 -67
  97. package/lib/control/layerSwitch.d.ts +0 -27
  98. package/lib/control/layerSwitch.js +0 -162
  99. package/lib/control/logo.d.ts +0 -14
  100. package/lib/control/logo.js +0 -55
  101. package/lib/control/mapTheme.d.ts +0 -11
  102. package/lib/control/mapTheme.js +0 -76
  103. package/lib/control/mouseLocation.d.ts +0 -16
  104. package/lib/control/mouseLocation.js +0 -59
  105. package/lib/control/scale.d.ts +0 -35
  106. package/lib/control/scale.js +0 -128
  107. package/lib/control/swipe.d.ts +0 -66
  108. package/lib/control/swipe.js +0 -399
  109. package/lib/control/zoom.d.ts +0 -39
  110. package/lib/control/zoom.js +0 -107
  111. package/lib/css/button.less +0 -77
  112. package/lib/css/control.less +0 -82
  113. package/lib/css/index.css +0 -653
  114. package/lib/css/index.less +0 -13
  115. package/lib/css/l7.less +0 -69
  116. package/lib/css/layerPopup.less +0 -9
  117. package/lib/css/logo.less +0 -21
  118. package/lib/css/mouseLocation.less +0 -9
  119. package/lib/css/popper.less +0 -74
  120. package/lib/css/popup.less +0 -176
  121. package/lib/css/scale.less +0 -37
  122. package/lib/css/select.less +0 -96
  123. package/lib/css/swipe.less +0 -80
  124. package/lib/css/variables.less +0 -29
  125. package/lib/css/zoom.less +0 -34
  126. package/lib/images/layers.png +0 -0
  127. package/lib/images/layers.svg +0 -1
  128. package/lib/images/logo.png +0 -0
  129. package/lib/images/quanping.svg +0 -12
  130. package/lib/index.d.ts +0 -19
  131. package/lib/index.js +0 -835
  132. package/lib/interface.d.ts +0 -29
  133. package/lib/interface.js +0 -5
  134. package/lib/marker-layer.d.ts +0 -46
  135. package/lib/marker-layer.js +0 -518
  136. package/lib/marker.d.ts +0 -66
  137. package/lib/marker.js +0 -502
  138. package/lib/popup/layerPopup.d.ts +0 -105
  139. package/lib/popup/layerPopup.js +0 -348
  140. package/lib/popup/popup.d.ts +0 -147
  141. package/lib/popup/popup.js +0 -594
  142. package/lib/utils/anchor.d.ts +0 -22
  143. package/lib/utils/anchor.js +0 -38
  144. package/lib/utils/eventManager.d.ts +0 -42
  145. package/lib/utils/eventManager.js +0 -92
  146. package/lib/utils/icon.d.ts +0 -1
  147. package/lib/utils/icon.js +0 -19
  148. package/lib/utils/popper.d.ts +0 -76
  149. package/lib/utils/popper.js +0 -264
  150. package/lib/utils/screenfull.d.ts +0 -2
  151. package/lib/utils/screenfull.js +0 -112
@@ -1,35 +0,0 @@
1
- import type { IControlOption } from './baseControl';
2
- import { Control, PositionType } from './baseControl';
3
- export interface IScaleControlOption extends IControlOption {
4
- lockWidth: boolean;
5
- maxWidth: number;
6
- metric: boolean;
7
- updateWhenIdle: boolean;
8
- imperial: boolean;
9
- }
10
- export { Scale };
11
- export default class Scale extends Control<IScaleControlOption> {
12
- private mScale;
13
- private iScale;
14
- getDefault(option: Partial<IScaleControlOption>): {
15
- name: string;
16
- position: PositionType;
17
- maxWidth: number;
18
- metric: boolean;
19
- updateWhenIdle: boolean;
20
- imperial: boolean;
21
- lockWidth: boolean;
22
- className?: string | undefined;
23
- style?: string | undefined;
24
- };
25
- onAdd(): HTMLElement;
26
- onRemove(): void;
27
- setOptions(newOption: Partial<IScaleControlOption>): void;
28
- update: () => void;
29
- updateScales(maxMeters: number): void;
30
- private resetScaleLines;
31
- private updateScale;
32
- private getRoundNum;
33
- private updateMetric;
34
- private updateImperial;
35
- }
@@ -1,121 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import { DOM, lnglatDistance } from '@antv/l7-utils';
4
- import { Control, PositionType } from "./baseControl";
5
- export { Scale };
6
- export default class Scale extends Control {
7
- constructor(...args) {
8
- super(...args);
9
- _defineProperty(this, "mScale", void 0);
10
- _defineProperty(this, "iScale", void 0);
11
- _defineProperty(this, "update", () => {
12
- const mapsService = this.mapsService;
13
- const {
14
- maxWidth
15
- } = this.controlOption;
16
- const y = mapsService.getSize()[1] / 2;
17
- const p1 = mapsService.containerToLngLat([0, y]);
18
- const p2 = mapsService.containerToLngLat([maxWidth, y]);
19
- const maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
20
- this.updateScales(maxMeters);
21
- });
22
- }
23
- getDefault(option) {
24
- return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
25
- name: 'scale',
26
- position: PositionType.BOTTOMLEFT,
27
- maxWidth: 100,
28
- metric: true,
29
- updateWhenIdle: false,
30
- imperial: false,
31
- lockWidth: true
32
- });
33
- }
34
- onAdd() {
35
- const className = 'l7-control-scale';
36
- const container = DOM.create('div', className);
37
- this.resetScaleLines(container);
38
- const {
39
- updateWhenIdle
40
- } = this.controlOption;
41
- this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
42
- this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
43
- return container;
44
- }
45
- onRemove() {
46
- const {
47
- updateWhenIdle
48
- } = this.controlOption;
49
- this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
50
- this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
51
- }
52
- setOptions(newOption) {
53
- super.setOptions(newOption);
54
- if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
55
- this.resetScaleLines(this.container);
56
- }
57
- }
58
- updateScales(maxMeters) {
59
- const {
60
- metric,
61
- imperial
62
- } = this.controlOption;
63
- if (metric && maxMeters) {
64
- this.updateMetric(maxMeters);
65
- }
66
- if (imperial && maxMeters) {
67
- this.updateImperial(maxMeters);
68
- }
69
- }
70
- resetScaleLines(container) {
71
- DOM.clearChildren(container);
72
- const {
73
- metric,
74
- imperial,
75
- maxWidth,
76
- lockWidth
77
- } = this.controlOption;
78
- if (lockWidth) {
79
- DOM.addStyle(container, `width: ${maxWidth}px`);
80
- }
81
- if (metric) {
82
- this.mScale = DOM.create('div', 'l7-control-scale-line', container);
83
- }
84
- if (imperial) {
85
- this.iScale = DOM.create('div', 'l7-control-scale-line', container);
86
- }
87
- this.update();
88
- }
89
- updateScale(scale, text, ratio) {
90
- const {
91
- maxWidth
92
- } = this.controlOption;
93
- scale.style.width = Math.round(maxWidth * ratio) + 'px';
94
- scale.innerHTML = text;
95
- }
96
- getRoundNum(num) {
97
- const pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
98
- let d = num / pow10;
99
- d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
100
- return pow10 * d;
101
- }
102
- updateMetric(maxMeters) {
103
- const meters = this.getRoundNum(maxMeters);
104
- const label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
105
- this.updateScale(this.mScale, label, meters / maxMeters);
106
- }
107
- updateImperial(maxMeters) {
108
- const maxFeet = maxMeters * 3.2808399;
109
- let maxMiles;
110
- let miles;
111
- let feet;
112
- if (maxFeet > 5280) {
113
- maxMiles = maxFeet / 5280;
114
- miles = this.getRoundNum(maxMiles);
115
- this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
116
- } else {
117
- feet = this.getRoundNum(maxFeet);
118
- this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
119
- }
120
- }
121
- }
@@ -1,66 +0,0 @@
1
- import type { ILayer, L7Container } from '@antv/l7-core';
2
- import type { IControlOption } from './baseControl';
3
- import { Control } from './baseControl';
4
- export interface ISwipeControlOption extends IControlOption {
5
- /**
6
- * 左侧的图层
7
- */
8
- layers: ILayer[];
9
- /**
10
- * 右侧的图层
11
- */
12
- rightLayers: ILayer[];
13
- /**
14
- * 设置卷帘的位置,值域为 0 到 1, 默认正中间为 0.5
15
- */
16
- ratio?: number;
17
- /**
18
- * 卷帘方向设置('vertical' | 'horizontal'),默认 'vertical'
19
- */
20
- orientation?: 'vertical' | 'horizontal';
21
- }
22
- export { Swipe };
23
- export default class Swipe extends Control<ISwipeControlOption> {
24
- /**
25
- * 是否正在拖动卷帘
26
- */
27
- private isMoving;
28
- /**
29
- * 掩模图层实例
30
- */
31
- private maskLayer;
32
- getDefault(): ISwipeControlOption;
33
- onAdd(): HTMLElement;
34
- addTo(sceneContainer: L7Container): this;
35
- onRemove(): void;
36
- show(): void;
37
- hide(): void;
38
- setOptions(newOptions: Partial<ISwipeControlOption>): void;
39
- private registerEvent;
40
- private unRegisterEvent;
41
- private setOrientationAndRatio;
42
- private setLayers;
43
- private addMaskToLayers;
44
- private removeMaskFromLayers;
45
- private move;
46
- private getMaskGeoData;
47
- private getMaskLayer;
48
- private updateMask;
49
- private getContainerDOMRect;
50
- private getContainerSize;
51
- private getBounds;
52
- /**
53
- * 添加要剪裁的图层
54
- * @param layer 剪裁的图层
55
- * @param addRight 是否添加图层到右侧, 默认添加到左侧.
56
- */
57
- addLayer(layer: ILayer | ILayer[], addRight?: boolean): void;
58
- /**
59
- * 移除剪裁的图层
60
- */
61
- removeLayer(layer: ILayer | ILayer[]): void;
62
- /**
63
- * 清除所有图层
64
- */
65
- removeLayers(): void;
66
- }
@@ -1,392 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import { createLayerContainer } from '@antv/l7-core';
4
- import { PolygonLayer } from '@antv/l7-layers';
5
- import { DOM } from '@antv/l7-utils';
6
- import { Control } from "./baseControl";
7
- export { Swipe };
8
- export default class Swipe extends Control {
9
- constructor(...args) {
10
- super(...args);
11
- /**
12
- * 是否正在拖动卷帘
13
- */
14
- _defineProperty(this, "isMoving", false);
15
- /**
16
- * 掩模图层实例
17
- */
18
- _defineProperty(this, "maskLayer", void 0);
19
- _defineProperty(this, "move", e => {
20
- // 阻止事件冒泡到地图上
21
- e.stopPropagation();
22
- switch (e.type) {
23
- case 'touchcancel':
24
- case 'touchend':
25
- case 'mouseup':
26
- {
27
- var _this$scene;
28
- this.isMoving = false;
29
- ['mouseup', 'mousemove', 'touchend', 'touchcancel', 'touchmove'].forEach(eventName => {
30
- document.removeEventListener(eventName, this.move);
31
- });
32
- (_this$scene = this.scene) === null || _this$scene === void 0 || _this$scene.render();
33
- break;
34
- }
35
- case 'mousedown':
36
- case 'touchstart':
37
- {
38
- this.isMoving = true;
39
- ['mouseup', 'mousemove', 'touchend', 'touchcancel', 'touchmove'].forEach(eventName => {
40
- document.addEventListener(eventName, this.move);
41
- });
42
- // fallthrough
43
- }
44
- case 'mousemove':
45
- case 'touchmove':
46
- {
47
- if (this.isMoving) {
48
- if (this.controlOption.orientation === 'vertical') {
49
- let pageX;
50
- if ('pageX' in e) {
51
- pageX = e.pageX;
52
- } else if (e.touches && e.touches.length && e.touches[0].pageX) {
53
- pageX = e.touches[0].pageX;
54
- } else if (e.changedTouches && e.changedTouches.length) {
55
- pageX = e.changedTouches[0].pageX;
56
- }
57
- if (!pageX) {
58
- break;
59
- }
60
- const containerRect = this.getContainerDOMRect();
61
- const containerSize = this.getContainerSize();
62
- const containerWidth = containerSize[0];
63
- const containerRectLeft = (containerRect === null || containerRect === void 0 ? void 0 : containerRect.left) || 0;
64
- const offsetX = pageX - containerRectLeft + window.scrollX - document.documentElement.clientLeft;
65
- const width = containerWidth - Math.min(Math.max(0, containerWidth - offsetX), containerWidth);
66
- const ratio = width / containerWidth;
67
- this.setOptions({
68
- ratio
69
- });
70
- this.emit('moving', {
71
- size: [width, containerSize[1]],
72
- ratio: [ratio, 0]
73
- });
74
- } else {
75
- let pageY;
76
- if ('pageY' in e) {
77
- pageY = e.pageY;
78
- } else if (e.touches && e.touches.length && e.touches[0].pageY) {
79
- pageY = e.touches[0].pageY;
80
- } else if (e.changedTouches && e.changedTouches.length) {
81
- pageY = e.changedTouches[0].pageY;
82
- }
83
- if (!pageY) {
84
- break;
85
- }
86
- const containerRect = this.getContainerDOMRect();
87
- const containerSize = this.getContainerSize();
88
- const containerHeight = containerSize[1];
89
- const containerRectLeft = (containerRect === null || containerRect === void 0 ? void 0 : containerRect.top) || 0;
90
- const offsetY = pageY - containerRectLeft + window.scrollY - document.documentElement.clientTop;
91
- const height = containerHeight - Math.min(Math.max(0, containerHeight - offsetY), containerHeight);
92
- const ratio = height / containerHeight;
93
- this.setOptions({
94
- ratio
95
- });
96
- this.emit('moving', {
97
- size: [containerSize[0], height],
98
- ratio: [0, ratio]
99
- });
100
- }
101
- }
102
- break;
103
- }
104
- default:
105
- break;
106
- }
107
- });
108
- _defineProperty(this, "getMaskLayer", () => {
109
- console.log(this.getMaskGeoData());
110
- return new PolygonLayer({
111
- visible: false
112
- }).source(this.getMaskGeoData()).shape('fill').color('red').style({
113
- opacity: 0.1
114
- });
115
- });
116
- _defineProperty(this, "updateMask", () => {
117
- var _this$maskLayer;
118
- if (!this.mapsService) return;
119
- const geoJSON = this.getMaskGeoData();
120
- (_this$maskLayer = this.maskLayer) === null || _this$maskLayer === void 0 || _this$maskLayer.setData(geoJSON);
121
- });
122
- }
123
- getDefault() {
124
- return _objectSpread(_objectSpread({}, super.getDefault()), {}, {
125
- layers: [],
126
- rightLayers: [],
127
- ratio: 0.5,
128
- orientation: 'vertical'
129
- });
130
- }
131
- onAdd() {
132
- const container = DOM.create('div', 'l7-control-swipe');
133
- DOM.create('button', 'l7-control-swipe__button', container);
134
- const {
135
- orientation = 'vertical',
136
- ratio = 0.5
137
- } = this.controlOption;
138
- if (orientation === 'horizontal') {
139
- container.style.top = ratio * 100 + '%';
140
- container.style.left = '';
141
- } else {
142
- container.style.left = ratio * 100 + '%';
143
- container.style.top = '';
144
- }
145
- container.classList.add(orientation);
146
- return container;
147
- }
148
- addTo(sceneContainer) {
149
- // 初始化各个 Service 实例
150
- this.mapsService = sceneContainer.mapService;
151
- this.renderService = sceneContainer.rendererService;
152
- this.layerService = sceneContainer.layerService;
153
- this.controlService = sceneContainer.controlService;
154
- this.configService = sceneContainer.globalConfigService;
155
- this.scene = sceneContainer.sceneService;
156
- this.sceneContainer = sceneContainer;
157
- this.isShow = true;
158
-
159
- // 初始化 container
160
- this.container = this.onAdd();
161
- const {
162
- className,
163
- style,
164
- layers,
165
- rightLayers
166
- } = this.controlOption;
167
- if (className) {
168
- this.setClassName(className);
169
- }
170
- if (style) {
171
- this.setStyle(style);
172
- }
173
-
174
- // 将 container 插入容器中
175
- // this.scene.getSceneContainer().appendChild(this.container);
176
- this.mapsService.getMarkerContainer().appendChild(this.container);
177
- this.maskLayer = this.getMaskLayer();
178
- this.registerEvent();
179
-
180
- // 添加掩模图层到 scene
181
- const layerContainer = createLayerContainer(sceneContainer);
182
- this.maskLayer.setContainer(layerContainer);
183
- this.scene.addLayer(this.maskLayer);
184
-
185
- // 给图层挂载掩模
186
- this.addMaskToLayers(layers, false);
187
- this.addMaskToLayers(rightLayers, true);
188
- this.emit('add', this);
189
- return this;
190
- }
191
- onRemove() {
192
- if (this.maskLayer) {
193
- var _this$layerService;
194
- const {
195
- layers,
196
- rightLayers
197
- } = this.controlOption;
198
- this.removeMaskFromLayers(layers);
199
- this.removeMaskFromLayers(rightLayers);
200
- (_this$layerService = this.layerService) === null || _this$layerService === void 0 || _this$layerService.remove(this.maskLayer);
201
- }
202
- this.unRegisterEvent();
203
- this.removeAllListeners();
204
- }
205
- show() {
206
- var _this$scene2;
207
- const container = this.container;
208
- DOM.removeClass(container, 'l7-control-swipe_hide');
209
- // 启用掩模
210
- const {
211
- layers,
212
- rightLayers
213
- } = this.controlOption;
214
- layers.forEach(layer => layer.enableMask());
215
- rightLayers.forEach(layer => layer.enableMask());
216
- (_this$scene2 = this.scene) === null || _this$scene2 === void 0 || _this$scene2.render();
217
- this.isShow = true;
218
- this.emit('show', this);
219
- }
220
- hide() {
221
- var _this$scene3;
222
- const container = this.container;
223
- DOM.addClass(container, 'l7-control-swipe_hide');
224
- // 禁用掩模
225
- const {
226
- layers,
227
- rightLayers
228
- } = this.controlOption;
229
- layers.forEach(layer => layer.disableMask());
230
- rightLayers.forEach(layer => layer.disableMask());
231
- (_this$scene3 = this.scene) === null || _this$scene3 === void 0 || _this$scene3.render();
232
- this.isShow = false;
233
- this.emit('hide', this);
234
- }
235
- setOptions(newOptions) {
236
- const controlOption = _objectSpread(_objectSpread({}, this.controlOption), newOptions);
237
- if (newOptions.className) {
238
- this.setClassName(newOptions.className);
239
- }
240
- if (newOptions.style) {
241
- this.setStyle(newOptions.style);
242
- }
243
- if (newOptions.orientation || newOptions.ratio !== undefined) {
244
- this.setOrientationAndRatio(controlOption.orientation, controlOption.ratio);
245
- }
246
- if (newOptions.layers) {
247
- const newLayers = newOptions.layers;
248
- const oldLayers = this.controlOption.layers;
249
- this.setLayers(newLayers, oldLayers, false);
250
- }
251
- if (newOptions.rightLayers) {
252
- const newLayers = newOptions.rightLayers;
253
- const oldLayers = this.controlOption.rightLayers;
254
- this.setLayers(newLayers, oldLayers, true);
255
- }
256
- this.controlOption = controlOption;
257
- this.updateMask();
258
- }
259
- registerEvent() {
260
- this.container.addEventListener('mousedown', this.move);
261
- this.container.addEventListener('touchstart', this.move);
262
- this.mapsService.on('camerachange', this.updateMask);
263
- }
264
- unRegisterEvent() {
265
- var _this$mapsService;
266
- this.container.removeEventListener('mousedown', this.move);
267
- this.container.removeEventListener('touchstart', this.move);
268
- (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 || _this$mapsService.off('camerachange', this.updateMask);
269
- }
270
- setOrientationAndRatio(orientation = 'vertical', ratio = 0.5) {
271
- this.container.classList.remove('horizontal', 'vertical');
272
- this.container.classList.add(orientation);
273
- if (orientation === 'horizontal') {
274
- this.container.style.top = ratio * 100 + '%';
275
- this.container.style.left = '';
276
- } else {
277
- this.container.style.left = ratio * 100 + '%';
278
- this.container.style.top = '';
279
- }
280
- }
281
- setLayers(newLayers, oldLayers, isRightLayer = false) {
282
- const addLayers = newLayers.filter(layer => oldLayers.includes(layer) === false);
283
- const removeLayers = oldLayers.filter(layer => newLayers.includes(layer) === false);
284
- this.addMaskToLayers(addLayers, isRightLayer);
285
- this.removeMaskFromLayers(removeLayers);
286
- }
287
- addMaskToLayers(layers, isRightLayer) {
288
- layers.forEach(layer => {
289
- layer.updateLayerConfig({
290
- maskInside: isRightLayer ? false : true
291
- });
292
- layer.addMask(this.maskLayer);
293
- });
294
- }
295
- removeMaskFromLayers(layers) {
296
- layers.forEach(layer => {
297
- // reset default is true
298
- layer.updateLayerConfig({
299
- maskInside: true
300
- });
301
- layer.removeMask(this.maskLayer);
302
- });
303
- }
304
- getMaskGeoData() {
305
- const {
306
- ratio = 0.5,
307
- orientation = 'vertical'
308
- } = this.controlOption;
309
- const isVertical = orientation === 'vertical';
310
- const [sw, ne] = this.getBounds();
311
- const [swLng, swLat] = sw;
312
- const [neLng, neLat] = ne;
313
- let coordinate;
314
- if (isVertical) {
315
- const centerLng = swLng + (neLng - swLng) * ratio;
316
- coordinate = [[swLng, neLat], [centerLng, neLat], [centerLng, swLat], sw, [swLng, neLat]];
317
- } else {
318
- const size = this.getContainerSize();
319
- const lngLat = this.mapsService.containerToLngLat([size[0], size[1] * ratio]);
320
- const centerLat = lngLat.lat;
321
- coordinate = [[swLng, neLat], ne, [neLng, centerLat], [swLng, centerLat], [swLng, neLat]];
322
- }
323
- const geoJSON = {
324
- type: 'FeatureCollection',
325
- features: [{
326
- type: 'Feature',
327
- properties: {},
328
- geometry: {
329
- type: 'Polygon',
330
- coordinates: [coordinate]
331
- }
332
- }]
333
- };
334
- return geoJSON;
335
- }
336
- getContainerDOMRect() {
337
- var _this$mapsService$get;
338
- const rect = (_this$mapsService$get = this.mapsService.getContainer()) === null || _this$mapsService$get === void 0 ? void 0 : _this$mapsService$get.getBoundingClientRect();
339
- return rect;
340
- }
341
- getContainerSize() {
342
- const size = this.mapsService.getSize();
343
- return size;
344
- }
345
- getBounds() {
346
- const bounds = this.mapsService.getBounds();
347
- return bounds;
348
- }
349
-
350
- /**
351
- * 添加要剪裁的图层
352
- * @param layer 剪裁的图层
353
- * @param addRight 是否添加图层到右侧, 默认添加到左侧.
354
- */
355
- addLayer(layer, addRight = false) {
356
- const layers = Array.isArray(layer) ? layer : [layer];
357
- if (addRight) {
358
- const rightLayers = this.controlOption.rightLayers.concat(...layers);
359
- this.setOptions({
360
- rightLayers
361
- });
362
- } else {
363
- const leftLayers = this.controlOption.layers.concat(...layers);
364
- this.setOptions({
365
- layers: leftLayers
366
- });
367
- }
368
- }
369
-
370
- /**
371
- * 移除剪裁的图层
372
- */
373
- removeLayer(layer) {
374
- const layers = Array.isArray(layer) ? layer : [layer];
375
- const leftLayers = this.controlOption.layers.filter(layer => layers.includes(layer));
376
- const rightLayers = this.controlOption.rightLayers.filter(layer => layers.includes(layer));
377
- this.setOptions({
378
- layers: leftLayers,
379
- rightLayers
380
- });
381
- }
382
-
383
- /**
384
- * 清除所有图层
385
- */
386
- removeLayers() {
387
- this.setOptions({
388
- layers: [],
389
- rightLayers: []
390
- });
391
- }
392
- }
@@ -1,39 +0,0 @@
1
- import { PositionType } from '@antv/l7-core';
2
- import { DOM } from '@antv/l7-utils';
3
- import type { IControlOption } from './baseControl';
4
- import { Control } from './baseControl';
5
- export interface IZoomControlOption extends IControlOption {
6
- zoomInText: DOM.ELType | string;
7
- zoomInTitle: string;
8
- zoomOutText: DOM.ELType | string;
9
- zoomOutTitle: string;
10
- showZoom: boolean;
11
- }
12
- export { Zoom };
13
- export default class Zoom extends Control<IZoomControlOption> {
14
- private disabled;
15
- private zoomInButton;
16
- private zoomOutButton;
17
- private zoomNumDiv;
18
- getDefault(option: Partial<IZoomControlOption>): {
19
- position: PositionType;
20
- name: string;
21
- zoomInText: SVGSVGElement;
22
- zoomInTitle: string;
23
- zoomOutText: SVGSVGElement;
24
- zoomOutTitle: string;
25
- showZoom: boolean;
26
- className?: string | undefined;
27
- style?: string | undefined;
28
- };
29
- setOptions(newOptions: Partial<IZoomControlOption>): void;
30
- onAdd(): HTMLElement;
31
- onRemove(): void;
32
- disable(): this;
33
- enable(): this;
34
- zoomIn: () => void;
35
- zoomOut: () => void;
36
- private resetButtonGroup;
37
- private createButton;
38
- private updateDisabled;
39
- }