@antv/l7-component 2.20.5 → 2.20.8
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
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Swipe = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
+
var _l7Core = require("@antv/l7-core");
|
|
20
|
+
var _l7Layers = require("@antv/l7-layers");
|
|
21
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
22
|
+
var _baseControl = require("./baseControl");
|
|
23
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
24
|
+
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; } }
|
|
25
|
+
var Swipe = exports.default = exports.Swipe = /*#__PURE__*/function (_Control) {
|
|
26
|
+
(0, _inherits2.default)(Swipe, _Control);
|
|
27
|
+
var _super = _createSuper(Swipe);
|
|
28
|
+
function Swipe() {
|
|
29
|
+
var _this;
|
|
30
|
+
(0, _classCallCheck2.default)(this, Swipe);
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
35
|
+
/**
|
|
36
|
+
* 是否正在拖动卷帘
|
|
37
|
+
*/
|
|
38
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMoving", false);
|
|
39
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "move", function (e) {
|
|
40
|
+
// 阻止事件冒泡到地图上
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
switch (e.type) {
|
|
43
|
+
case 'touchcancel':
|
|
44
|
+
case 'touchend':
|
|
45
|
+
case 'mouseup':
|
|
46
|
+
{
|
|
47
|
+
var _this$scene;
|
|
48
|
+
_this.isMoving = false;
|
|
49
|
+
['mouseup', 'mousemove', 'touchend', 'touchcancel', 'touchmove'].forEach(function (eventName) {
|
|
50
|
+
document.removeEventListener(eventName, _this.move);
|
|
51
|
+
});
|
|
52
|
+
(_this$scene = _this.scene) === null || _this$scene === void 0 || _this$scene.render();
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'mousedown':
|
|
56
|
+
case 'touchstart':
|
|
57
|
+
{
|
|
58
|
+
_this.isMoving = true;
|
|
59
|
+
['mouseup', 'mousemove', 'touchend', 'touchcancel', 'touchmove'].forEach(function (eventName) {
|
|
60
|
+
document.addEventListener(eventName, _this.move);
|
|
61
|
+
});
|
|
62
|
+
// fallthrough
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
case 'mousemove':
|
|
66
|
+
case 'touchmove':
|
|
67
|
+
{
|
|
68
|
+
if (_this.isMoving) {
|
|
69
|
+
if (_this.controlOption.orientation === 'vertical') {
|
|
70
|
+
var pageX;
|
|
71
|
+
if ('pageX' in e) {
|
|
72
|
+
pageX = e.pageX;
|
|
73
|
+
} else if (e.touches && e.touches.length && e.touches[0].pageX) {
|
|
74
|
+
pageX = e.touches[0].pageX;
|
|
75
|
+
} else if (e.changedTouches && e.changedTouches.length) {
|
|
76
|
+
pageX = e.changedTouches[0].pageX;
|
|
77
|
+
}
|
|
78
|
+
if (!pageX) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
var containerRect = _this.getContainerDOMRect();
|
|
82
|
+
var containerSize = _this.getContainerSize();
|
|
83
|
+
var containerWidth = containerSize[0];
|
|
84
|
+
var containerRectLeft = (containerRect === null || containerRect === void 0 ? void 0 : containerRect.left) || 0;
|
|
85
|
+
var offsetX = pageX - containerRectLeft + window.scrollX - document.documentElement.clientLeft;
|
|
86
|
+
var width = containerWidth - Math.min(Math.max(0, containerWidth - offsetX), containerWidth);
|
|
87
|
+
var ratio = width / containerWidth;
|
|
88
|
+
_this.setOptions({
|
|
89
|
+
ratio: ratio
|
|
90
|
+
});
|
|
91
|
+
_this.emit('moving', {
|
|
92
|
+
size: [width, containerSize[1]],
|
|
93
|
+
ratio: [ratio, 0]
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
var pageY;
|
|
97
|
+
if ('pageY' in e) {
|
|
98
|
+
pageY = e.pageY;
|
|
99
|
+
} else if (e.touches && e.touches.length && e.touches[0].pageY) {
|
|
100
|
+
pageY = e.touches[0].pageY;
|
|
101
|
+
} else if (e.changedTouches && e.changedTouches.length) {
|
|
102
|
+
pageY = e.changedTouches[0].pageY;
|
|
103
|
+
}
|
|
104
|
+
if (!pageY) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
var _containerRect = _this.getContainerDOMRect();
|
|
108
|
+
var _containerSize = _this.getContainerSize();
|
|
109
|
+
var containerHeight = _containerSize[1];
|
|
110
|
+
var _containerRectLeft = (_containerRect === null || _containerRect === void 0 ? void 0 : _containerRect.top) || 0;
|
|
111
|
+
var offsetY = pageY - _containerRectLeft + window.scrollY - document.documentElement.clientTop;
|
|
112
|
+
var height = containerHeight - Math.min(Math.max(0, containerHeight - offsetY), containerHeight);
|
|
113
|
+
var _ratio = height / containerHeight;
|
|
114
|
+
_this.setOptions({
|
|
115
|
+
ratio: _ratio
|
|
116
|
+
});
|
|
117
|
+
_this.emit('moving', {
|
|
118
|
+
size: [_containerSize[0], height],
|
|
119
|
+
ratio: [0, _ratio]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
default:
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getMaskLayer", function () {
|
|
130
|
+
return new _l7Layers.PolygonLayer({
|
|
131
|
+
visible: false
|
|
132
|
+
}).source({
|
|
133
|
+
type: 'FeatureCollection',
|
|
134
|
+
features: []
|
|
135
|
+
}).shape('fill').color('red').style({
|
|
136
|
+
opacity: 0.1
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateMask", function () {
|
|
140
|
+
var _this$maskLayer;
|
|
141
|
+
if (!_this.mapsService) return;
|
|
142
|
+
var geoJSON = _this.getMaskGeoData();
|
|
143
|
+
(_this$maskLayer = _this.maskLayer) === null || _this$maskLayer === void 0 || _this$maskLayer.setData(geoJSON);
|
|
144
|
+
});
|
|
145
|
+
return _this;
|
|
146
|
+
}
|
|
147
|
+
(0, _createClass2.default)(Swipe, [{
|
|
148
|
+
key: "getDefault",
|
|
149
|
+
value:
|
|
150
|
+
/**
|
|
151
|
+
* 掩膜图层实例
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
function getDefault() {
|
|
155
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(Swipe.prototype), "getDefault", this).call(this)), {}, {
|
|
156
|
+
layers: [],
|
|
157
|
+
rightLayers: [],
|
|
158
|
+
ratio: 0.5,
|
|
159
|
+
orientation: 'vertical'
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "onAdd",
|
|
164
|
+
value: function onAdd() {
|
|
165
|
+
var container = _l7Utils.DOM.create('div', 'l7-control-swipe');
|
|
166
|
+
_l7Utils.DOM.create('button', 'l7-control-swipe__button', container);
|
|
167
|
+
var _this$controlOption = this.controlOption,
|
|
168
|
+
_this$controlOption$o = _this$controlOption.orientation,
|
|
169
|
+
orientation = _this$controlOption$o === void 0 ? 'vertical' : _this$controlOption$o,
|
|
170
|
+
_this$controlOption$r = _this$controlOption.ratio,
|
|
171
|
+
ratio = _this$controlOption$r === void 0 ? 0.5 : _this$controlOption$r;
|
|
172
|
+
if (orientation === 'horizontal') {
|
|
173
|
+
container.style.top = ratio * 100 + '%';
|
|
174
|
+
container.style.left = '';
|
|
175
|
+
} else {
|
|
176
|
+
container.style.left = ratio * 100 + '%';
|
|
177
|
+
container.style.top = '';
|
|
178
|
+
}
|
|
179
|
+
container.classList.add(orientation);
|
|
180
|
+
return container;
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "addTo",
|
|
184
|
+
value: function addTo(sceneContainer) {
|
|
185
|
+
// 初始化各个 Service 实例
|
|
186
|
+
this.mapsService = sceneContainer.get(_l7Core.TYPES.IMapService);
|
|
187
|
+
this.renderService = sceneContainer.get(_l7Core.TYPES.IRendererService);
|
|
188
|
+
this.layerService = sceneContainer.get(_l7Core.TYPES.ILayerService);
|
|
189
|
+
this.controlService = sceneContainer.get(_l7Core.TYPES.IControlService);
|
|
190
|
+
this.configService = sceneContainer.get(_l7Core.TYPES.IGlobalConfigService);
|
|
191
|
+
this.scene = sceneContainer.get(_l7Core.TYPES.ISceneService);
|
|
192
|
+
this.sceneContainer = sceneContainer;
|
|
193
|
+
this.isShow = true;
|
|
194
|
+
|
|
195
|
+
// 初始化 container
|
|
196
|
+
this.container = this.onAdd();
|
|
197
|
+
var _this$controlOption2 = this.controlOption,
|
|
198
|
+
className = _this$controlOption2.className,
|
|
199
|
+
style = _this$controlOption2.style,
|
|
200
|
+
layers = _this$controlOption2.layers,
|
|
201
|
+
rightLayers = _this$controlOption2.rightLayers;
|
|
202
|
+
if (className) {
|
|
203
|
+
this.setClassName(className);
|
|
204
|
+
}
|
|
205
|
+
if (style) {
|
|
206
|
+
this.setStyle(style);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 将 container 插入容器中
|
|
210
|
+
// this.scene.getSceneContainer().appendChild(this.container);
|
|
211
|
+
this.mapsService.getMarkerContainer().appendChild(this.container);
|
|
212
|
+
this.maskLayer = this.getMaskLayer();
|
|
213
|
+
this.updateMask();
|
|
214
|
+
this.registerEvent();
|
|
215
|
+
|
|
216
|
+
// 给图层挂载掩膜
|
|
217
|
+
this.addMaskToLayers(layers, false);
|
|
218
|
+
this.addMaskToLayers(rightLayers, true);
|
|
219
|
+
|
|
220
|
+
// 添加掩膜图层到 scene
|
|
221
|
+
var layerContainer = (0, _l7Core.createLayerContainer)(sceneContainer);
|
|
222
|
+
this.maskLayer.setContainer(layerContainer, sceneContainer);
|
|
223
|
+
this.scene.addLayer(this.maskLayer);
|
|
224
|
+
this.emit('add', this);
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
key: "onRemove",
|
|
229
|
+
value: function onRemove() {
|
|
230
|
+
if (this.maskLayer) {
|
|
231
|
+
var _this$layerService;
|
|
232
|
+
var _this$controlOption3 = this.controlOption,
|
|
233
|
+
layers = _this$controlOption3.layers,
|
|
234
|
+
rightLayers = _this$controlOption3.rightLayers;
|
|
235
|
+
this.removeMaskFromLayers(layers);
|
|
236
|
+
this.removeMaskFromLayers(rightLayers);
|
|
237
|
+
(_this$layerService = this.layerService) === null || _this$layerService === void 0 || _this$layerService.remove(this.maskLayer);
|
|
238
|
+
}
|
|
239
|
+
this.unRegisterEvent();
|
|
240
|
+
this.removeAllListeners();
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "show",
|
|
244
|
+
value: function show() {
|
|
245
|
+
var _this$scene2;
|
|
246
|
+
var container = this.container;
|
|
247
|
+
_l7Utils.DOM.removeClass(container, 'l7-control-swipe_hide');
|
|
248
|
+
// 启用掩膜
|
|
249
|
+
var _this$controlOption4 = this.controlOption,
|
|
250
|
+
layers = _this$controlOption4.layers,
|
|
251
|
+
rightLayers = _this$controlOption4.rightLayers;
|
|
252
|
+
layers.forEach(function (layer) {
|
|
253
|
+
return layer.enableMask();
|
|
254
|
+
});
|
|
255
|
+
rightLayers.forEach(function (layer) {
|
|
256
|
+
return layer.enableMask();
|
|
257
|
+
});
|
|
258
|
+
(_this$scene2 = this.scene) === null || _this$scene2 === void 0 || _this$scene2.render();
|
|
259
|
+
this.isShow = true;
|
|
260
|
+
this.emit('show', this);
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "hide",
|
|
264
|
+
value: function hide() {
|
|
265
|
+
var _this$scene3;
|
|
266
|
+
var container = this.container;
|
|
267
|
+
_l7Utils.DOM.addClass(container, 'l7-control-swipe_hide');
|
|
268
|
+
// 禁用掩膜
|
|
269
|
+
var _this$controlOption5 = this.controlOption,
|
|
270
|
+
layers = _this$controlOption5.layers,
|
|
271
|
+
rightLayers = _this$controlOption5.rightLayers;
|
|
272
|
+
layers.forEach(function (layer) {
|
|
273
|
+
return layer.disableMask();
|
|
274
|
+
});
|
|
275
|
+
rightLayers.forEach(function (layer) {
|
|
276
|
+
return layer.disableMask();
|
|
277
|
+
});
|
|
278
|
+
(_this$scene3 = this.scene) === null || _this$scene3 === void 0 || _this$scene3.render();
|
|
279
|
+
this.isShow = false;
|
|
280
|
+
this.emit('hide', this);
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "setOptions",
|
|
284
|
+
value: function setOptions(newOptions) {
|
|
285
|
+
var controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.controlOption), newOptions);
|
|
286
|
+
if (newOptions.className) {
|
|
287
|
+
this.setClassName(newOptions.className);
|
|
288
|
+
}
|
|
289
|
+
if (newOptions.style) {
|
|
290
|
+
this.setStyle(newOptions.style);
|
|
291
|
+
}
|
|
292
|
+
if (newOptions.orientation || newOptions.ratio !== undefined) {
|
|
293
|
+
this.setOrientationAndRatio(controlOption.orientation, controlOption.ratio);
|
|
294
|
+
}
|
|
295
|
+
if (newOptions.layers) {
|
|
296
|
+
var newLayers = newOptions.layers;
|
|
297
|
+
var oldLayers = this.controlOption.layers;
|
|
298
|
+
this.setLayers(newLayers, oldLayers, false);
|
|
299
|
+
}
|
|
300
|
+
if (newOptions.rightLayers) {
|
|
301
|
+
var _newLayers = newOptions.rightLayers;
|
|
302
|
+
var _oldLayers = this.controlOption.rightLayers;
|
|
303
|
+
this.setLayers(_newLayers, _oldLayers, true);
|
|
304
|
+
}
|
|
305
|
+
this.controlOption = controlOption;
|
|
306
|
+
this.updateMask();
|
|
307
|
+
}
|
|
308
|
+
}, {
|
|
309
|
+
key: "registerEvent",
|
|
310
|
+
value: function registerEvent() {
|
|
311
|
+
this.container.addEventListener('mousedown', this.move);
|
|
312
|
+
this.container.addEventListener('touchstart', this.move);
|
|
313
|
+
this.mapsService.on('camerachange', this.updateMask);
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
key: "unRegisterEvent",
|
|
317
|
+
value: function unRegisterEvent() {
|
|
318
|
+
var _this$mapsService;
|
|
319
|
+
this.container.removeEventListener('mousedown', this.move);
|
|
320
|
+
this.container.removeEventListener('touchstart', this.move);
|
|
321
|
+
(_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 || _this$mapsService.off('camerachange', this.updateMask);
|
|
322
|
+
}
|
|
323
|
+
}, {
|
|
324
|
+
key: "setOrientationAndRatio",
|
|
325
|
+
value: function setOrientationAndRatio() {
|
|
326
|
+
var orientation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical';
|
|
327
|
+
var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
|
|
328
|
+
this.container.classList.remove('horizontal', 'vertical');
|
|
329
|
+
this.container.classList.add(orientation);
|
|
330
|
+
if (orientation === 'horizontal') {
|
|
331
|
+
this.container.style.top = ratio * 100 + '%';
|
|
332
|
+
this.container.style.left = '';
|
|
333
|
+
} else {
|
|
334
|
+
this.container.style.left = ratio * 100 + '%';
|
|
335
|
+
this.container.style.top = '';
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}, {
|
|
339
|
+
key: "setLayers",
|
|
340
|
+
value: function setLayers(newLayers, oldLayers) {
|
|
341
|
+
var isRightLayer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
342
|
+
var addLayers = newLayers.filter(function (layer) {
|
|
343
|
+
return oldLayers.includes(layer) === false;
|
|
344
|
+
});
|
|
345
|
+
var removeLayers = oldLayers.filter(function (layer) {
|
|
346
|
+
return newLayers.includes(layer) === false;
|
|
347
|
+
});
|
|
348
|
+
this.addMaskToLayers(addLayers, isRightLayer);
|
|
349
|
+
this.removeMaskFromLayers(removeLayers);
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
key: "addMaskToLayers",
|
|
353
|
+
value: function addMaskToLayers(layers, isRightLayer) {
|
|
354
|
+
var _this2 = this;
|
|
355
|
+
layers.forEach(function (layer) {
|
|
356
|
+
layer.updateLayerConfig({
|
|
357
|
+
maskInside: isRightLayer ? false : true
|
|
358
|
+
});
|
|
359
|
+
layer.addMask(_this2.maskLayer);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
key: "removeMaskFromLayers",
|
|
364
|
+
value: function removeMaskFromLayers(layers) {
|
|
365
|
+
var _this3 = this;
|
|
366
|
+
layers.forEach(function (layer) {
|
|
367
|
+
// reset default is true
|
|
368
|
+
layer.updateLayerConfig({
|
|
369
|
+
maskInside: true
|
|
370
|
+
});
|
|
371
|
+
layer.removeMask(_this3.maskLayer);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}, {
|
|
375
|
+
key: "getMaskGeoData",
|
|
376
|
+
value: function getMaskGeoData() {
|
|
377
|
+
var _this$controlOption6 = this.controlOption,
|
|
378
|
+
_this$controlOption6$ = _this$controlOption6.ratio,
|
|
379
|
+
ratio = _this$controlOption6$ === void 0 ? 0.5 : _this$controlOption6$,
|
|
380
|
+
_this$controlOption6$2 = _this$controlOption6.orientation,
|
|
381
|
+
orientation = _this$controlOption6$2 === void 0 ? 'vertical' : _this$controlOption6$2;
|
|
382
|
+
var isVertical = orientation === 'vertical';
|
|
383
|
+
var _this$getBounds = this.getBounds(),
|
|
384
|
+
_this$getBounds2 = (0, _slicedToArray2.default)(_this$getBounds, 2),
|
|
385
|
+
sw = _this$getBounds2[0],
|
|
386
|
+
ne = _this$getBounds2[1];
|
|
387
|
+
var _sw = (0, _slicedToArray2.default)(sw, 2),
|
|
388
|
+
swLng = _sw[0],
|
|
389
|
+
swLat = _sw[1];
|
|
390
|
+
var _ne = (0, _slicedToArray2.default)(ne, 2),
|
|
391
|
+
neLng = _ne[0],
|
|
392
|
+
neLat = _ne[1];
|
|
393
|
+
var coordinate;
|
|
394
|
+
if (isVertical) {
|
|
395
|
+
var centerLng = swLng + (neLng - swLng) * ratio;
|
|
396
|
+
coordinate = [[swLng, neLat], [centerLng, neLat], [centerLng, swLat], sw, [swLng, neLat]];
|
|
397
|
+
} else {
|
|
398
|
+
var size = this.getContainerSize();
|
|
399
|
+
var lngLat = this.mapsService.containerToLngLat([size[0], size[1] * ratio]);
|
|
400
|
+
var centerLat = lngLat.lat;
|
|
401
|
+
coordinate = [[swLng, neLat], ne, [neLng, centerLat], [swLng, centerLat], [swLng, neLat]];
|
|
402
|
+
}
|
|
403
|
+
var geoJSON = {
|
|
404
|
+
type: 'FeatureCollection',
|
|
405
|
+
features: [{
|
|
406
|
+
type: 'Feature',
|
|
407
|
+
properties: {},
|
|
408
|
+
geometry: {
|
|
409
|
+
type: 'Polygon',
|
|
410
|
+
coordinates: [coordinate]
|
|
411
|
+
}
|
|
412
|
+
}]
|
|
413
|
+
};
|
|
414
|
+
return geoJSON;
|
|
415
|
+
}
|
|
416
|
+
}, {
|
|
417
|
+
key: "getContainerDOMRect",
|
|
418
|
+
value: function getContainerDOMRect() {
|
|
419
|
+
var _this$mapsService$get;
|
|
420
|
+
var rect = (_this$mapsService$get = this.mapsService.getContainer()) === null || _this$mapsService$get === void 0 ? void 0 : _this$mapsService$get.getBoundingClientRect();
|
|
421
|
+
return rect;
|
|
422
|
+
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "getContainerSize",
|
|
425
|
+
value: function getContainerSize() {
|
|
426
|
+
var size = this.mapsService.getSize();
|
|
427
|
+
return size;
|
|
428
|
+
}
|
|
429
|
+
}, {
|
|
430
|
+
key: "getBounds",
|
|
431
|
+
value: function getBounds() {
|
|
432
|
+
var bounds = this.mapsService.getBounds();
|
|
433
|
+
return bounds;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 添加要剪裁的图层
|
|
438
|
+
* @param layer 剪裁的图层
|
|
439
|
+
* @param addRight 是否添加图层到右侧, 默认添加到左侧.
|
|
440
|
+
*/
|
|
441
|
+
}, {
|
|
442
|
+
key: "addLayer",
|
|
443
|
+
value: function addLayer(layer) {
|
|
444
|
+
var addRight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
445
|
+
var layers = Array.isArray(layer) ? layer : [layer];
|
|
446
|
+
if (addRight) {
|
|
447
|
+
var _this$controlOption$r2;
|
|
448
|
+
var rightLayers = (_this$controlOption$r2 = this.controlOption.rightLayers).concat.apply(_this$controlOption$r2, (0, _toConsumableArray2.default)(layers));
|
|
449
|
+
this.setOptions({
|
|
450
|
+
rightLayers: rightLayers
|
|
451
|
+
});
|
|
452
|
+
} else {
|
|
453
|
+
var _this$controlOption$l;
|
|
454
|
+
var leftLayers = (_this$controlOption$l = this.controlOption.layers).concat.apply(_this$controlOption$l, (0, _toConsumableArray2.default)(layers));
|
|
455
|
+
this.setOptions({
|
|
456
|
+
layers: leftLayers
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* 移除剪裁的图层
|
|
463
|
+
*/
|
|
464
|
+
}, {
|
|
465
|
+
key: "removeLayer",
|
|
466
|
+
value: function removeLayer(layer) {
|
|
467
|
+
var layers = Array.isArray(layer) ? layer : [layer];
|
|
468
|
+
var leftLayers = this.controlOption.layers.filter(function (layer) {
|
|
469
|
+
return layers.includes(layer);
|
|
470
|
+
});
|
|
471
|
+
var rightLayers = this.controlOption.rightLayers.filter(function (layer) {
|
|
472
|
+
return layers.includes(layer);
|
|
473
|
+
});
|
|
474
|
+
this.setOptions({
|
|
475
|
+
layers: leftLayers,
|
|
476
|
+
rightLayers: rightLayers
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* 清除所有图层
|
|
482
|
+
*/
|
|
483
|
+
}, {
|
|
484
|
+
key: "removeLayers",
|
|
485
|
+
value: function removeLayers() {
|
|
486
|
+
this.setOptions({
|
|
487
|
+
layers: [],
|
|
488
|
+
rightLayers: []
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}]);
|
|
492
|
+
return Swipe;
|
|
493
|
+
}(_baseControl.Control);
|
package/lib/css/index.css
CHANGED
|
@@ -590,3 +590,75 @@
|
|
|
590
590
|
.l7-layer-popup__row + .l7-layer-popup__row {
|
|
591
591
|
margin-top: 4px;
|
|
592
592
|
}
|
|
593
|
+
.l7-control-swipe {
|
|
594
|
+
position: absolute;
|
|
595
|
+
top: 50%;
|
|
596
|
+
left: 50%;
|
|
597
|
+
z-index: 6;
|
|
598
|
+
transform: translate(-50%, -50%);
|
|
599
|
+
touch-action: none;
|
|
600
|
+
}
|
|
601
|
+
.l7-control-swipe_hide {
|
|
602
|
+
display: none;
|
|
603
|
+
}
|
|
604
|
+
.l7-control-swipe:before {
|
|
605
|
+
position: absolute;
|
|
606
|
+
top: -5000px;
|
|
607
|
+
bottom: -5000px;
|
|
608
|
+
left: 50%;
|
|
609
|
+
z-index: -1;
|
|
610
|
+
width: 4px;
|
|
611
|
+
background: #fff;
|
|
612
|
+
transform: translate(-2px, 0);
|
|
613
|
+
content: '';
|
|
614
|
+
}
|
|
615
|
+
.l7-control-swipe.horizontal:before {
|
|
616
|
+
top: 50%;
|
|
617
|
+
right: -5000px;
|
|
618
|
+
bottom: auto;
|
|
619
|
+
left: -5000px;
|
|
620
|
+
width: auto;
|
|
621
|
+
height: 4px;
|
|
622
|
+
}
|
|
623
|
+
.l7-control-swipe__button {
|
|
624
|
+
display: block;
|
|
625
|
+
width: 28px;
|
|
626
|
+
height: 28px;
|
|
627
|
+
margin: 0;
|
|
628
|
+
padding: 0;
|
|
629
|
+
color: #595959;
|
|
630
|
+
font-weight: bold;
|
|
631
|
+
font-size: inherit;
|
|
632
|
+
text-align: center;
|
|
633
|
+
text-decoration: none;
|
|
634
|
+
background-color: #fff;
|
|
635
|
+
border: none;
|
|
636
|
+
border-radius: 2px;
|
|
637
|
+
outline: none;
|
|
638
|
+
}
|
|
639
|
+
.l7-control-swipe,
|
|
640
|
+
.l7-control-swipe__button {
|
|
641
|
+
cursor: ew-resize;
|
|
642
|
+
}
|
|
643
|
+
.l7-control-swipe.horizontal,
|
|
644
|
+
.l7-control-swipe.horizontal button {
|
|
645
|
+
cursor: ns-resize;
|
|
646
|
+
}
|
|
647
|
+
.l7-control-swipe:after,
|
|
648
|
+
.l7-control-swipe__button:before,
|
|
649
|
+
.l7-control-swipe__button:after {
|
|
650
|
+
position: absolute;
|
|
651
|
+
top: 25%;
|
|
652
|
+
bottom: 25%;
|
|
653
|
+
left: 50%;
|
|
654
|
+
width: 2px;
|
|
655
|
+
background: currentColor;
|
|
656
|
+
transform: translate(-1px, 0);
|
|
657
|
+
content: '';
|
|
658
|
+
}
|
|
659
|
+
.l7-control-swipe__button:after {
|
|
660
|
+
transform: translateX(4px);
|
|
661
|
+
}
|
|
662
|
+
.l7-control-swipe__button:before {
|
|
663
|
+
transform: translateX(-6px);
|
|
664
|
+
}
|
package/lib/css/index.less
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
@import 'variables';
|
|
2
|
+
|
|
3
|
+
.l7-control-swipe {
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: 50%;
|
|
6
|
+
left: 50%;
|
|
7
|
+
z-index: 6;
|
|
8
|
+
transform: translate(-50%, -50%);
|
|
9
|
+
touch-action: none;
|
|
10
|
+
|
|
11
|
+
&_hide {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&:before {
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: -5000px;
|
|
18
|
+
bottom: -5000px;
|
|
19
|
+
left: 50%;
|
|
20
|
+
z-index: -1;
|
|
21
|
+
width: 4px;
|
|
22
|
+
background: #fff;
|
|
23
|
+
transform: translate(-2px, 0);
|
|
24
|
+
content: '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.horizontal:before {
|
|
28
|
+
top: 50%;
|
|
29
|
+
right: -5000px;
|
|
30
|
+
bottom: auto;
|
|
31
|
+
left: -5000px;
|
|
32
|
+
width: auto;
|
|
33
|
+
height: 4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__button {
|
|
37
|
+
display: block;
|
|
38
|
+
width: @l7-btn-control-size;
|
|
39
|
+
height: @l7-btn-control-size;
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
color: @l7-control-font-color;
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
font-size: inherit;
|
|
45
|
+
text-align: center;
|
|
46
|
+
text-decoration: none;
|
|
47
|
+
background-color: @l7-control-bg-color;
|
|
48
|
+
border: none;
|
|
49
|
+
border-radius: 2px;
|
|
50
|
+
outline: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&,
|
|
54
|
+
&__button {
|
|
55
|
+
cursor: ew-resize;
|
|
56
|
+
}
|
|
57
|
+
&.horizontal,
|
|
58
|
+
&.horizontal button {
|
|
59
|
+
cursor: ns-resize;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:after,
|
|
63
|
+
&__button:before,
|
|
64
|
+
&__button:after {
|
|
65
|
+
position: absolute;
|
|
66
|
+
top: 25%;
|
|
67
|
+
bottom: 25%;
|
|
68
|
+
left: 50%;
|
|
69
|
+
width: 2px;
|
|
70
|
+
background: currentColor;
|
|
71
|
+
transform: translate(-1px, 0);
|
|
72
|
+
content: '';
|
|
73
|
+
}
|
|
74
|
+
&__button:after {
|
|
75
|
+
transform: translateX(4px);
|
|
76
|
+
}
|
|
77
|
+
&__button:before {
|
|
78
|
+
transform: translateX(-6px);
|
|
79
|
+
}
|
|
80
|
+
}
|