@antv/l7-component 2.20.5 → 2.20.6
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/es/control/baseControl/buttonControl.d.ts +2 -1
- package/es/control/baseControl/control.d.ts +4 -3
- package/es/control/baseControl/popperControl.d.ts +4 -2
- package/es/control/baseControl/selectControl.d.ts +2 -1
- package/es/control/exportImage.d.ts +2 -1
- package/es/control/fullscreen.d.ts +2 -1
- package/es/control/geoLocate.d.ts +3 -2
- package/es/control/layerSwitch.d.ts +3 -2
- package/es/control/logo.d.ts +2 -1
- package/es/control/mapTheme.d.ts +2 -1
- package/es/control/mouseLocation.d.ts +3 -2
- package/es/control/scale.d.ts +2 -1
- package/es/control/swipe.d.ts +67 -0
- package/es/control/swipe.js +488 -0
- package/es/control/zoom.d.ts +2 -1
- package/es/css/index.css +72 -0
- package/es/css/index.less +1 -0
- package/es/css/swipe.less +80 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/marker-layer.d.ts +3 -3
- package/es/marker.d.ts +2 -2
- package/es/popup/layerPopup.d.ts +2 -2
- package/es/popup/popup.d.ts +2 -2
- package/lib/control/swipe.js +493 -0
- package/lib/css/index.css +72 -0
- package/lib/css/index.less +1 -0
- package/lib/css/swipe.less +80 -0
- package/lib/index.js +9 -1
- package/package.json +7 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DOM } from '@antv/l7-utils';
|
|
2
|
-
import
|
|
2
|
+
import type { IControlOption } from './control';
|
|
3
|
+
import Control from './control';
|
|
3
4
|
export { ButtonControl };
|
|
4
5
|
export interface IButtonControlOption extends IControlOption {
|
|
5
6
|
btnIcon?: DOM.ELType | DocumentFragment;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { IControl, IControlService, IGlobalConfigService, ILayerService, IMapService, IRendererService, ISceneService, PositionName
|
|
1
|
+
import type { IControl, IControlService, IGlobalConfigService, ILayerService, IMapService, IRendererService, ISceneService, PositionName } from '@antv/l7-core';
|
|
2
|
+
import { PositionType } from '@antv/l7-core';
|
|
2
3
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import { Container } from 'inversify';
|
|
4
|
-
import { ControlEvent } from '../../interface';
|
|
4
|
+
import type { Container } from 'inversify';
|
|
5
|
+
import type { ControlEvent } from '../../interface';
|
|
5
6
|
export { PositionType } from '@antv/l7-core';
|
|
6
7
|
export { Control };
|
|
7
8
|
export interface IControlOption {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { PopperPlacement, PopperTrigger } from '../../utils/popper';
|
|
2
|
+
import { Popper } from '../../utils/popper';
|
|
3
|
+
import type { IButtonControlOption } from './buttonControl';
|
|
4
|
+
import ButtonControl from './buttonControl';
|
|
3
5
|
export { PopperControl };
|
|
4
6
|
export interface IPopperControlOption extends IButtonControlOption {
|
|
5
7
|
popperPlacement: PopperPlacement;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { IButtonControlOption } from './baseControl/buttonControl';
|
|
2
|
+
import ButtonControl from './baseControl/buttonControl';
|
|
2
3
|
export interface IExportImageControlOption extends IButtonControlOption {
|
|
3
4
|
imageType: 'png' | 'jpeg';
|
|
4
5
|
onExport: (base64: string) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { IButtonControlOption } from './baseControl/buttonControl';
|
|
2
|
+
import ButtonControl from './baseControl/buttonControl';
|
|
2
3
|
export interface IFullscreenControlOption extends IButtonControlOption {
|
|
3
4
|
exitBtnText: IButtonControlOption['btnText'];
|
|
4
5
|
exitBtnIcon: IButtonControlOption['btnIcon'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Point } from '@antv/l7-core';
|
|
2
|
-
import
|
|
1
|
+
import type { Point } from '@antv/l7-core';
|
|
2
|
+
import type { IButtonControlOption } from './baseControl/buttonControl';
|
|
3
|
+
import ButtonControl from './baseControl/buttonControl';
|
|
3
4
|
export interface IGeoLocateOption extends IButtonControlOption {
|
|
4
5
|
transform: (position: Point) => Point | Promise<Point>;
|
|
5
6
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ILayer } from '@antv/l7-core';
|
|
2
|
-
import
|
|
1
|
+
import type { ILayer } from '@antv/l7-core';
|
|
2
|
+
import type { ControlOptionItem, ISelectControlOption } from './baseControl/selectControl';
|
|
3
|
+
import SelectControl from './baseControl/selectControl';
|
|
3
4
|
export type LayerSwitchItem = {
|
|
4
5
|
layer: ILayer;
|
|
5
6
|
name?: string;
|
package/es/control/logo.d.ts
CHANGED
package/es/control/mapTheme.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ControlOptionItem, ISelectControlOption } from './baseControl/selectControl';
|
|
2
|
+
import SelectControl from './baseControl/selectControl';
|
|
2
3
|
export { MapTheme };
|
|
3
4
|
export default class MapTheme extends SelectControl<ISelectControlOption> {
|
|
4
5
|
getDefault(option?: Partial<ISelectControlOption>): ISelectControlOption;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Position } from '@antv/l7-core';
|
|
2
|
-
import
|
|
1
|
+
import type { Position } from '@antv/l7-core';
|
|
2
|
+
import type { IControlOption } from './baseControl/control';
|
|
3
|
+
import Control from './baseControl/control';
|
|
3
4
|
export interface IMouseLocationControlOption extends IControlOption {
|
|
4
5
|
transform: (position: Position) => Position;
|
|
5
6
|
}
|
package/es/control/scale.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IControlOption } from './baseControl';
|
|
2
|
+
import { Control, PositionType } from './baseControl';
|
|
2
3
|
export interface IScaleControlOption extends IControlOption {
|
|
3
4
|
lockWidth: boolean;
|
|
4
5
|
maxWidth: number;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ILayer } from '@antv/l7-core';
|
|
2
|
+
import type { Container } from 'inversify';
|
|
3
|
+
import type { IControlOption } from './baseControl';
|
|
4
|
+
import { Control } from './baseControl';
|
|
5
|
+
export interface ISwipeControlOption extends IControlOption {
|
|
6
|
+
/**
|
|
7
|
+
* 左侧的图层
|
|
8
|
+
*/
|
|
9
|
+
layers: ILayer[];
|
|
10
|
+
/**
|
|
11
|
+
* 右侧的图层
|
|
12
|
+
*/
|
|
13
|
+
rightLayers: ILayer[];
|
|
14
|
+
/**
|
|
15
|
+
* 设置卷帘的位置,值域为 0 到 1, 默认正中间为 0.5
|
|
16
|
+
*/
|
|
17
|
+
ratio?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 卷帘方向设置('vertical' | 'horizontal'),默认 'vertical'
|
|
20
|
+
*/
|
|
21
|
+
orientation?: 'vertical' | 'horizontal';
|
|
22
|
+
}
|
|
23
|
+
export { Swipe };
|
|
24
|
+
export default class Swipe extends Control<ISwipeControlOption> {
|
|
25
|
+
/**
|
|
26
|
+
* 是否正在拖动卷帘
|
|
27
|
+
*/
|
|
28
|
+
private isMoving;
|
|
29
|
+
/**
|
|
30
|
+
* 掩膜图层实例
|
|
31
|
+
*/
|
|
32
|
+
private maskLayer;
|
|
33
|
+
getDefault(): ISwipeControlOption;
|
|
34
|
+
onAdd(): HTMLElement;
|
|
35
|
+
addTo(sceneContainer: Container): this;
|
|
36
|
+
onRemove(): void;
|
|
37
|
+
show(): void;
|
|
38
|
+
hide(): void;
|
|
39
|
+
setOptions(newOptions: Partial<ISwipeControlOption>): void;
|
|
40
|
+
private registerEvent;
|
|
41
|
+
private unRegisterEvent;
|
|
42
|
+
private setOrientationAndRatio;
|
|
43
|
+
private setLayers;
|
|
44
|
+
private addMaskToLayers;
|
|
45
|
+
private removeMaskFromLayers;
|
|
46
|
+
private move;
|
|
47
|
+
private getMaskGeoData;
|
|
48
|
+
private getMaskLayer;
|
|
49
|
+
private updateMask;
|
|
50
|
+
private getContainerDOMRect;
|
|
51
|
+
private getContainerSize;
|
|
52
|
+
private getBounds;
|
|
53
|
+
/**
|
|
54
|
+
* 添加要剪裁的图层
|
|
55
|
+
* @param layer 剪裁的图层
|
|
56
|
+
* @param addRight 是否添加图层到右侧, 默认添加到左侧.
|
|
57
|
+
*/
|
|
58
|
+
addLayer(layer: ILayer | ILayer[], addRight?: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* 移除剪裁的图层
|
|
61
|
+
*/
|
|
62
|
+
removeLayer(layer: ILayer | ILayer[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* 清除所有图层
|
|
65
|
+
*/
|
|
66
|
+
removeLayers(): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
7
|
+
import _get from "@babel/runtime/helpers/esm/get";
|
|
8
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
10
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
11
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
12
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
import { TYPES, createLayerContainer } from '@antv/l7-core';
|
|
15
|
+
import { PolygonLayer } from '@antv/l7-layers';
|
|
16
|
+
import { DOM } from '@antv/l7-utils';
|
|
17
|
+
import { Control } from "./baseControl";
|
|
18
|
+
export { Swipe };
|
|
19
|
+
var Swipe = /*#__PURE__*/function (_Control) {
|
|
20
|
+
_inherits(Swipe, _Control);
|
|
21
|
+
var _super = _createSuper(Swipe);
|
|
22
|
+
function Swipe() {
|
|
23
|
+
var _this;
|
|
24
|
+
_classCallCheck(this, Swipe);
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
29
|
+
/**
|
|
30
|
+
* 是否正在拖动卷帘
|
|
31
|
+
*/
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "isMoving", false);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "move", function (e) {
|
|
34
|
+
// 阻止事件冒泡到地图上
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
switch (e.type) {
|
|
37
|
+
case 'touchcancel':
|
|
38
|
+
case 'touchend':
|
|
39
|
+
case 'mouseup':
|
|
40
|
+
{
|
|
41
|
+
var _this$scene;
|
|
42
|
+
_this.isMoving = false;
|
|
43
|
+
['mouseup', 'mousemove', 'touchend', 'touchcancel', 'touchmove'].forEach(function (eventName) {
|
|
44
|
+
document.removeEventListener(eventName, _this.move);
|
|
45
|
+
});
|
|
46
|
+
(_this$scene = _this.scene) === null || _this$scene === void 0 || _this$scene.render();
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'mousedown':
|
|
50
|
+
case 'touchstart':
|
|
51
|
+
{
|
|
52
|
+
_this.isMoving = true;
|
|
53
|
+
['mouseup', 'mousemove', 'touchend', 'touchcancel', 'touchmove'].forEach(function (eventName) {
|
|
54
|
+
document.addEventListener(eventName, _this.move);
|
|
55
|
+
});
|
|
56
|
+
// fallthrough
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case 'mousemove':
|
|
60
|
+
case 'touchmove':
|
|
61
|
+
{
|
|
62
|
+
if (_this.isMoving) {
|
|
63
|
+
if (_this.controlOption.orientation === 'vertical') {
|
|
64
|
+
var pageX;
|
|
65
|
+
if ('pageX' in e) {
|
|
66
|
+
pageX = e.pageX;
|
|
67
|
+
} else if (e.touches && e.touches.length && e.touches[0].pageX) {
|
|
68
|
+
pageX = e.touches[0].pageX;
|
|
69
|
+
} else if (e.changedTouches && e.changedTouches.length) {
|
|
70
|
+
pageX = e.changedTouches[0].pageX;
|
|
71
|
+
}
|
|
72
|
+
if (!pageX) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
var containerRect = _this.getContainerDOMRect();
|
|
76
|
+
var containerSize = _this.getContainerSize();
|
|
77
|
+
var containerWidth = containerSize[0];
|
|
78
|
+
var containerRectLeft = (containerRect === null || containerRect === void 0 ? void 0 : containerRect.left) || 0;
|
|
79
|
+
var offsetX = pageX - containerRectLeft + window.scrollX - document.documentElement.clientLeft;
|
|
80
|
+
var width = containerWidth - Math.min(Math.max(0, containerWidth - offsetX), containerWidth);
|
|
81
|
+
var ratio = width / containerWidth;
|
|
82
|
+
_this.setOptions({
|
|
83
|
+
ratio: ratio
|
|
84
|
+
});
|
|
85
|
+
_this.emit('moving', {
|
|
86
|
+
size: [width, containerSize[1]],
|
|
87
|
+
ratio: [ratio, 0]
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
var pageY;
|
|
91
|
+
if ('pageY' in e) {
|
|
92
|
+
pageY = e.pageY;
|
|
93
|
+
} else if (e.touches && e.touches.length && e.touches[0].pageY) {
|
|
94
|
+
pageY = e.touches[0].pageY;
|
|
95
|
+
} else if (e.changedTouches && e.changedTouches.length) {
|
|
96
|
+
pageY = e.changedTouches[0].pageY;
|
|
97
|
+
}
|
|
98
|
+
if (!pageY) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
var _containerRect = _this.getContainerDOMRect();
|
|
102
|
+
var _containerSize = _this.getContainerSize();
|
|
103
|
+
var containerHeight = _containerSize[1];
|
|
104
|
+
var _containerRectLeft = (_containerRect === null || _containerRect === void 0 ? void 0 : _containerRect.top) || 0;
|
|
105
|
+
var offsetY = pageY - _containerRectLeft + window.scrollY - document.documentElement.clientTop;
|
|
106
|
+
var height = containerHeight - Math.min(Math.max(0, containerHeight - offsetY), containerHeight);
|
|
107
|
+
var _ratio = height / containerHeight;
|
|
108
|
+
_this.setOptions({
|
|
109
|
+
ratio: _ratio
|
|
110
|
+
});
|
|
111
|
+
_this.emit('moving', {
|
|
112
|
+
size: [_containerSize[0], height],
|
|
113
|
+
ratio: [0, _ratio]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
default:
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
_defineProperty(_assertThisInitialized(_this), "getMaskLayer", function () {
|
|
124
|
+
return new PolygonLayer({
|
|
125
|
+
visible: false
|
|
126
|
+
}).source({
|
|
127
|
+
type: 'FeatureCollection',
|
|
128
|
+
features: []
|
|
129
|
+
}).shape('fill').color('red').style({
|
|
130
|
+
opacity: 0.1
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
_defineProperty(_assertThisInitialized(_this), "updateMask", function () {
|
|
134
|
+
var _this$maskLayer;
|
|
135
|
+
if (!_this.mapsService) return;
|
|
136
|
+
var geoJSON = _this.getMaskGeoData();
|
|
137
|
+
(_this$maskLayer = _this.maskLayer) === null || _this$maskLayer === void 0 || _this$maskLayer.setData(geoJSON);
|
|
138
|
+
});
|
|
139
|
+
return _this;
|
|
140
|
+
}
|
|
141
|
+
_createClass(Swipe, [{
|
|
142
|
+
key: "getDefault",
|
|
143
|
+
value:
|
|
144
|
+
/**
|
|
145
|
+
* 掩膜图层实例
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
function getDefault() {
|
|
149
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Swipe.prototype), "getDefault", this).call(this)), {}, {
|
|
150
|
+
layers: [],
|
|
151
|
+
rightLayers: [],
|
|
152
|
+
ratio: 0.5,
|
|
153
|
+
orientation: 'vertical'
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "onAdd",
|
|
158
|
+
value: function onAdd() {
|
|
159
|
+
var container = DOM.create('div', 'l7-control-swipe');
|
|
160
|
+
DOM.create('button', 'l7-control-swipe__button', container);
|
|
161
|
+
var _this$controlOption = this.controlOption,
|
|
162
|
+
_this$controlOption$o = _this$controlOption.orientation,
|
|
163
|
+
orientation = _this$controlOption$o === void 0 ? 'vertical' : _this$controlOption$o,
|
|
164
|
+
_this$controlOption$r = _this$controlOption.ratio,
|
|
165
|
+
ratio = _this$controlOption$r === void 0 ? 0.5 : _this$controlOption$r;
|
|
166
|
+
if (orientation === 'horizontal') {
|
|
167
|
+
container.style.top = ratio * 100 + '%';
|
|
168
|
+
container.style.left = '';
|
|
169
|
+
} else {
|
|
170
|
+
container.style.left = ratio * 100 + '%';
|
|
171
|
+
container.style.top = '';
|
|
172
|
+
}
|
|
173
|
+
container.classList.add(orientation);
|
|
174
|
+
return container;
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "addTo",
|
|
178
|
+
value: function addTo(sceneContainer) {
|
|
179
|
+
// 初始化各个 Service 实例
|
|
180
|
+
this.mapsService = sceneContainer.get(TYPES.IMapService);
|
|
181
|
+
this.renderService = sceneContainer.get(TYPES.IRendererService);
|
|
182
|
+
this.layerService = sceneContainer.get(TYPES.ILayerService);
|
|
183
|
+
this.controlService = sceneContainer.get(TYPES.IControlService);
|
|
184
|
+
this.configService = sceneContainer.get(TYPES.IGlobalConfigService);
|
|
185
|
+
this.scene = sceneContainer.get(TYPES.ISceneService);
|
|
186
|
+
this.sceneContainer = sceneContainer;
|
|
187
|
+
this.isShow = true;
|
|
188
|
+
|
|
189
|
+
// 初始化 container
|
|
190
|
+
this.container = this.onAdd();
|
|
191
|
+
var _this$controlOption2 = this.controlOption,
|
|
192
|
+
className = _this$controlOption2.className,
|
|
193
|
+
style = _this$controlOption2.style,
|
|
194
|
+
layers = _this$controlOption2.layers,
|
|
195
|
+
rightLayers = _this$controlOption2.rightLayers;
|
|
196
|
+
if (className) {
|
|
197
|
+
this.setClassName(className);
|
|
198
|
+
}
|
|
199
|
+
if (style) {
|
|
200
|
+
this.setStyle(style);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 将 container 插入容器中
|
|
204
|
+
// this.scene.getSceneContainer().appendChild(this.container);
|
|
205
|
+
this.mapsService.getMarkerContainer().appendChild(this.container);
|
|
206
|
+
this.maskLayer = this.getMaskLayer();
|
|
207
|
+
this.updateMask();
|
|
208
|
+
this.registerEvent();
|
|
209
|
+
|
|
210
|
+
// 给图层挂载掩膜
|
|
211
|
+
this.addMaskToLayers(layers, false);
|
|
212
|
+
this.addMaskToLayers(rightLayers, true);
|
|
213
|
+
|
|
214
|
+
// 添加掩膜图层到 scene
|
|
215
|
+
var layerContainer = createLayerContainer(sceneContainer);
|
|
216
|
+
this.maskLayer.setContainer(layerContainer, sceneContainer);
|
|
217
|
+
this.scene.addLayer(this.maskLayer);
|
|
218
|
+
this.emit('add', this);
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "onRemove",
|
|
223
|
+
value: function onRemove() {
|
|
224
|
+
if (this.maskLayer) {
|
|
225
|
+
var _this$layerService;
|
|
226
|
+
var _this$controlOption3 = this.controlOption,
|
|
227
|
+
layers = _this$controlOption3.layers,
|
|
228
|
+
rightLayers = _this$controlOption3.rightLayers;
|
|
229
|
+
this.removeMaskFromLayers(layers);
|
|
230
|
+
this.removeMaskFromLayers(rightLayers);
|
|
231
|
+
(_this$layerService = this.layerService) === null || _this$layerService === void 0 || _this$layerService.remove(this.maskLayer);
|
|
232
|
+
}
|
|
233
|
+
this.unRegisterEvent();
|
|
234
|
+
this.removeAllListeners();
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
key: "show",
|
|
238
|
+
value: function show() {
|
|
239
|
+
var _this$scene2;
|
|
240
|
+
var container = this.container;
|
|
241
|
+
DOM.removeClass(container, 'l7-control-swipe_hide');
|
|
242
|
+
// 启用掩膜
|
|
243
|
+
var _this$controlOption4 = this.controlOption,
|
|
244
|
+
layers = _this$controlOption4.layers,
|
|
245
|
+
rightLayers = _this$controlOption4.rightLayers;
|
|
246
|
+
layers.forEach(function (layer) {
|
|
247
|
+
return layer.enableMask();
|
|
248
|
+
});
|
|
249
|
+
rightLayers.forEach(function (layer) {
|
|
250
|
+
return layer.enableMask();
|
|
251
|
+
});
|
|
252
|
+
(_this$scene2 = this.scene) === null || _this$scene2 === void 0 || _this$scene2.render();
|
|
253
|
+
this.isShow = true;
|
|
254
|
+
this.emit('show', this);
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
key: "hide",
|
|
258
|
+
value: function hide() {
|
|
259
|
+
var _this$scene3;
|
|
260
|
+
var container = this.container;
|
|
261
|
+
DOM.addClass(container, 'l7-control-swipe_hide');
|
|
262
|
+
// 禁用掩膜
|
|
263
|
+
var _this$controlOption5 = this.controlOption,
|
|
264
|
+
layers = _this$controlOption5.layers,
|
|
265
|
+
rightLayers = _this$controlOption5.rightLayers;
|
|
266
|
+
layers.forEach(function (layer) {
|
|
267
|
+
return layer.disableMask();
|
|
268
|
+
});
|
|
269
|
+
rightLayers.forEach(function (layer) {
|
|
270
|
+
return layer.disableMask();
|
|
271
|
+
});
|
|
272
|
+
(_this$scene3 = this.scene) === null || _this$scene3 === void 0 || _this$scene3.render();
|
|
273
|
+
this.isShow = false;
|
|
274
|
+
this.emit('hide', this);
|
|
275
|
+
}
|
|
276
|
+
}, {
|
|
277
|
+
key: "setOptions",
|
|
278
|
+
value: function setOptions(newOptions) {
|
|
279
|
+
var controlOption = _objectSpread(_objectSpread({}, this.controlOption), newOptions);
|
|
280
|
+
if (newOptions.className) {
|
|
281
|
+
this.setClassName(newOptions.className);
|
|
282
|
+
}
|
|
283
|
+
if (newOptions.style) {
|
|
284
|
+
this.setStyle(newOptions.style);
|
|
285
|
+
}
|
|
286
|
+
if (newOptions.orientation || newOptions.ratio !== undefined) {
|
|
287
|
+
this.setOrientationAndRatio(controlOption.orientation, controlOption.ratio);
|
|
288
|
+
}
|
|
289
|
+
if (newOptions.layers) {
|
|
290
|
+
var newLayers = newOptions.layers;
|
|
291
|
+
var oldLayers = this.controlOption.layers;
|
|
292
|
+
this.setLayers(newLayers, oldLayers, false);
|
|
293
|
+
}
|
|
294
|
+
if (newOptions.rightLayers) {
|
|
295
|
+
var _newLayers = newOptions.rightLayers;
|
|
296
|
+
var _oldLayers = this.controlOption.rightLayers;
|
|
297
|
+
this.setLayers(_newLayers, _oldLayers, true);
|
|
298
|
+
}
|
|
299
|
+
this.controlOption = controlOption;
|
|
300
|
+
this.updateMask();
|
|
301
|
+
}
|
|
302
|
+
}, {
|
|
303
|
+
key: "registerEvent",
|
|
304
|
+
value: function registerEvent() {
|
|
305
|
+
this.container.addEventListener('mousedown', this.move);
|
|
306
|
+
this.container.addEventListener('touchstart', this.move);
|
|
307
|
+
this.mapsService.on('camerachange', this.updateMask);
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
key: "unRegisterEvent",
|
|
311
|
+
value: function unRegisterEvent() {
|
|
312
|
+
var _this$mapsService;
|
|
313
|
+
this.container.removeEventListener('mousedown', this.move);
|
|
314
|
+
this.container.removeEventListener('touchstart', this.move);
|
|
315
|
+
(_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 || _this$mapsService.off('camerachange', this.updateMask);
|
|
316
|
+
}
|
|
317
|
+
}, {
|
|
318
|
+
key: "setOrientationAndRatio",
|
|
319
|
+
value: function setOrientationAndRatio() {
|
|
320
|
+
var orientation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical';
|
|
321
|
+
var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
|
|
322
|
+
this.container.classList.remove('horizontal', 'vertical');
|
|
323
|
+
this.container.classList.add(orientation);
|
|
324
|
+
if (orientation === 'horizontal') {
|
|
325
|
+
this.container.style.top = ratio * 100 + '%';
|
|
326
|
+
this.container.style.left = '';
|
|
327
|
+
} else {
|
|
328
|
+
this.container.style.left = ratio * 100 + '%';
|
|
329
|
+
this.container.style.top = '';
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "setLayers",
|
|
334
|
+
value: function setLayers(newLayers, oldLayers) {
|
|
335
|
+
var isRightLayer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
336
|
+
var addLayers = newLayers.filter(function (layer) {
|
|
337
|
+
return oldLayers.includes(layer) === false;
|
|
338
|
+
});
|
|
339
|
+
var removeLayers = oldLayers.filter(function (layer) {
|
|
340
|
+
return newLayers.includes(layer) === false;
|
|
341
|
+
});
|
|
342
|
+
this.addMaskToLayers(addLayers, isRightLayer);
|
|
343
|
+
this.removeMaskFromLayers(removeLayers);
|
|
344
|
+
}
|
|
345
|
+
}, {
|
|
346
|
+
key: "addMaskToLayers",
|
|
347
|
+
value: function addMaskToLayers(layers, isRightLayer) {
|
|
348
|
+
var _this2 = this;
|
|
349
|
+
layers.forEach(function (layer) {
|
|
350
|
+
layer.updateLayerConfig({
|
|
351
|
+
maskInside: isRightLayer ? false : true
|
|
352
|
+
});
|
|
353
|
+
layer.addMask(_this2.maskLayer);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "removeMaskFromLayers",
|
|
358
|
+
value: function removeMaskFromLayers(layers) {
|
|
359
|
+
var _this3 = this;
|
|
360
|
+
layers.forEach(function (layer) {
|
|
361
|
+
// reset default is true
|
|
362
|
+
layer.updateLayerConfig({
|
|
363
|
+
maskInside: true
|
|
364
|
+
});
|
|
365
|
+
layer.removeMask(_this3.maskLayer);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}, {
|
|
369
|
+
key: "getMaskGeoData",
|
|
370
|
+
value: function getMaskGeoData() {
|
|
371
|
+
var _this$controlOption6 = this.controlOption,
|
|
372
|
+
_this$controlOption6$ = _this$controlOption6.ratio,
|
|
373
|
+
ratio = _this$controlOption6$ === void 0 ? 0.5 : _this$controlOption6$,
|
|
374
|
+
_this$controlOption6$2 = _this$controlOption6.orientation,
|
|
375
|
+
orientation = _this$controlOption6$2 === void 0 ? 'vertical' : _this$controlOption6$2;
|
|
376
|
+
var isVertical = orientation === 'vertical';
|
|
377
|
+
var _this$getBounds = this.getBounds(),
|
|
378
|
+
_this$getBounds2 = _slicedToArray(_this$getBounds, 2),
|
|
379
|
+
sw = _this$getBounds2[0],
|
|
380
|
+
ne = _this$getBounds2[1];
|
|
381
|
+
var _sw = _slicedToArray(sw, 2),
|
|
382
|
+
swLng = _sw[0],
|
|
383
|
+
swLat = _sw[1];
|
|
384
|
+
var _ne = _slicedToArray(ne, 2),
|
|
385
|
+
neLng = _ne[0],
|
|
386
|
+
neLat = _ne[1];
|
|
387
|
+
var coordinate;
|
|
388
|
+
if (isVertical) {
|
|
389
|
+
var centerLng = swLng + (neLng - swLng) * ratio;
|
|
390
|
+
coordinate = [[swLng, neLat], [centerLng, neLat], [centerLng, swLat], sw, [swLng, neLat]];
|
|
391
|
+
} else {
|
|
392
|
+
var size = this.getContainerSize();
|
|
393
|
+
var lngLat = this.mapsService.containerToLngLat([size[0], size[1] * ratio]);
|
|
394
|
+
var centerLat = lngLat.lat;
|
|
395
|
+
coordinate = [[swLng, neLat], ne, [neLng, centerLat], [swLng, centerLat], [swLng, neLat]];
|
|
396
|
+
}
|
|
397
|
+
var geoJSON = {
|
|
398
|
+
type: 'FeatureCollection',
|
|
399
|
+
features: [{
|
|
400
|
+
type: 'Feature',
|
|
401
|
+
properties: {},
|
|
402
|
+
geometry: {
|
|
403
|
+
type: 'Polygon',
|
|
404
|
+
coordinates: [coordinate]
|
|
405
|
+
}
|
|
406
|
+
}]
|
|
407
|
+
};
|
|
408
|
+
return geoJSON;
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
key: "getContainerDOMRect",
|
|
412
|
+
value: function getContainerDOMRect() {
|
|
413
|
+
var _this$mapsService$get;
|
|
414
|
+
var rect = (_this$mapsService$get = this.mapsService.getContainer()) === null || _this$mapsService$get === void 0 ? void 0 : _this$mapsService$get.getBoundingClientRect();
|
|
415
|
+
return rect;
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
key: "getContainerSize",
|
|
419
|
+
value: function getContainerSize() {
|
|
420
|
+
var size = this.mapsService.getSize();
|
|
421
|
+
return size;
|
|
422
|
+
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "getBounds",
|
|
425
|
+
value: function getBounds() {
|
|
426
|
+
var bounds = this.mapsService.getBounds();
|
|
427
|
+
return bounds;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* 添加要剪裁的图层
|
|
432
|
+
* @param layer 剪裁的图层
|
|
433
|
+
* @param addRight 是否添加图层到右侧, 默认添加到左侧.
|
|
434
|
+
*/
|
|
435
|
+
}, {
|
|
436
|
+
key: "addLayer",
|
|
437
|
+
value: function addLayer(layer) {
|
|
438
|
+
var addRight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
439
|
+
var layers = Array.isArray(layer) ? layer : [layer];
|
|
440
|
+
if (addRight) {
|
|
441
|
+
var _this$controlOption$r2;
|
|
442
|
+
var rightLayers = (_this$controlOption$r2 = this.controlOption.rightLayers).concat.apply(_this$controlOption$r2, _toConsumableArray(layers));
|
|
443
|
+
this.setOptions({
|
|
444
|
+
rightLayers: rightLayers
|
|
445
|
+
});
|
|
446
|
+
} else {
|
|
447
|
+
var _this$controlOption$l;
|
|
448
|
+
var leftLayers = (_this$controlOption$l = this.controlOption.layers).concat.apply(_this$controlOption$l, _toConsumableArray(layers));
|
|
449
|
+
this.setOptions({
|
|
450
|
+
layers: leftLayers
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* 移除剪裁的图层
|
|
457
|
+
*/
|
|
458
|
+
}, {
|
|
459
|
+
key: "removeLayer",
|
|
460
|
+
value: function removeLayer(layer) {
|
|
461
|
+
var layers = Array.isArray(layer) ? layer : [layer];
|
|
462
|
+
var leftLayers = this.controlOption.layers.filter(function (layer) {
|
|
463
|
+
return layers.includes(layer);
|
|
464
|
+
});
|
|
465
|
+
var rightLayers = this.controlOption.rightLayers.filter(function (layer) {
|
|
466
|
+
return layers.includes(layer);
|
|
467
|
+
});
|
|
468
|
+
this.setOptions({
|
|
469
|
+
layers: leftLayers,
|
|
470
|
+
rightLayers: rightLayers
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* 清除所有图层
|
|
476
|
+
*/
|
|
477
|
+
}, {
|
|
478
|
+
key: "removeLayers",
|
|
479
|
+
value: function removeLayers() {
|
|
480
|
+
this.setOptions({
|
|
481
|
+
layers: [],
|
|
482
|
+
rightLayers: []
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}]);
|
|
486
|
+
return Swipe;
|
|
487
|
+
}(Control);
|
|
488
|
+
export { Swipe as default };
|
package/es/control/zoom.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PositionType } from '@antv/l7-core';
|
|
2
2
|
import { DOM } from '@antv/l7-utils';
|
|
3
|
-
import {
|
|
3
|
+
import type { IControlOption } from './baseControl';
|
|
4
|
+
import { Control } from './baseControl';
|
|
4
5
|
export interface IZoomControlOption extends IControlOption {
|
|
5
6
|
zoomInText: DOM.ELType | string;
|
|
6
7
|
zoomInTitle: string;
|