@antv/l7-component 2.15.2 → 2.15.4
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/assets/iconfont/iconfont.js +10 -17
- package/es/control/baseControl/buttonControl.js +9 -42
- package/es/control/baseControl/control.js +24 -53
- package/es/control/baseControl/popperControl.js +10 -24
- package/es/control/baseControl/selectControl.js +6 -45
- package/es/control/exportImage.js +76 -116
- package/es/control/fullscreen.js +20 -53
- package/es/control/geoLocate.js +36 -66
- package/es/control/layerSwitch.js +0 -31
- package/es/control/logo.js +2 -14
- package/es/control/mapTheme.js +7 -32
- package/es/control/mouseLocation.js +2 -23
- package/es/control/scale.js +6 -29
- package/es/control/zoom.js +0 -23
- package/es/index.js +2 -12
- package/es/marker-layer.js +41 -75
- package/es/marker.js +31 -85
- package/es/popup/layerPopup.js +31 -82
- package/es/popup/popup.js +48 -127
- package/es/utils/anchor.js +3 -7
- package/es/utils/popper.js +15 -64
- package/es/utils/screenfull.js +23 -52
- package/lib/assets/iconfont/iconfont.js +10 -17
- package/lib/control/baseControl/buttonControl.js +9 -52
- package/lib/control/baseControl/control.js +24 -68
- package/lib/control/baseControl/index.js +0 -8
- package/lib/control/baseControl/popperControl.js +10 -29
- package/lib/control/baseControl/selectControl.js +6 -60
- package/lib/control/exportImage.js +76 -125
- package/lib/control/fullscreen.js +20 -60
- package/lib/control/geoLocate.js +36 -75
- package/lib/control/layerSwitch.js +0 -36
- package/lib/control/logo.js +2 -26
- package/lib/control/mapTheme.js +7 -42
- package/lib/control/mouseLocation.js +2 -33
- package/lib/control/scale.js +6 -40
- package/lib/control/zoom.js +0 -33
- package/lib/index.js +0 -41
- package/lib/marker-layer.js +39 -86
- package/lib/marker.js +30 -92
- package/lib/popup/layerPopup.js +29 -94
- package/lib/popup/popup.js +48 -139
- package/lib/utils/anchor.js +4 -9
- package/lib/utils/icon.js +0 -2
- package/lib/utils/popper.js +14 -71
- package/lib/utils/screenfull.js +23 -54
- package/package.json +6 -6
package/es/marker.js
CHANGED
|
@@ -6,51 +6,37 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
-
|
|
10
9
|
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); }; }
|
|
11
|
-
|
|
12
10
|
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; } }
|
|
13
|
-
|
|
14
11
|
import { TYPES } from '@antv/l7-core';
|
|
15
|
-
import { anchorTranslate, anchorType, applyAnchorClass, bindAll, DOM,
|
|
12
|
+
import { anchorTranslate, anchorType, applyAnchorClass, bindAll, DOM, isPC } from '@antv/l7-utils';
|
|
16
13
|
import { EventEmitter } from 'eventemitter3';
|
|
17
|
-
|
|
18
14
|
// marker 支持 dragger 未完成
|
|
19
15
|
var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
20
16
|
_inherits(Marker, _EventEmitter);
|
|
21
|
-
|
|
22
17
|
var _super = _createSuper(Marker);
|
|
23
|
-
|
|
24
18
|
function Marker(option) {
|
|
25
19
|
var _this;
|
|
26
|
-
|
|
27
20
|
_classCallCheck(this, Marker);
|
|
28
|
-
|
|
29
21
|
_this = _super.call(this);
|
|
30
|
-
|
|
31
22
|
_defineProperty(_assertThisInitialized(_this), "added", false);
|
|
32
|
-
|
|
33
23
|
_defineProperty(_assertThisInitialized(_this), "eventHandle", function (e) {
|
|
34
24
|
_this.polyfillEvent(e);
|
|
35
|
-
|
|
36
25
|
_this.emit(e.type, {
|
|
37
26
|
target: e,
|
|
38
27
|
data: _this.markerOption.extData,
|
|
39
28
|
lngLat: _this.lngLat
|
|
40
29
|
});
|
|
41
30
|
});
|
|
42
|
-
|
|
43
31
|
_this.markerOption = _objectSpread(_objectSpread({}, _this.getDefault()), option);
|
|
44
32
|
bindAll(['update', 'onMove', 'onMapClick'], _assertThisInitialized(_this));
|
|
45
|
-
|
|
46
33
|
_this.init();
|
|
47
|
-
|
|
48
34
|
return _this;
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
_createClass(Marker, [{
|
|
52
37
|
key: "getMarkerLayerContainerSize",
|
|
53
|
-
value:
|
|
38
|
+
value:
|
|
39
|
+
// tslint:disable-next-line: no-empty
|
|
54
40
|
function getMarkerLayerContainerSize() {}
|
|
55
41
|
}, {
|
|
56
42
|
key: "getDefault",
|
|
@@ -71,12 +57,11 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
71
57
|
this.scene = scene;
|
|
72
58
|
this.mapsService = scene.get(TYPES.IMapService);
|
|
73
59
|
this.sceneSerive = scene.get(TYPES.ISceneService);
|
|
74
|
-
var element = this.markerOption.element;
|
|
75
|
-
|
|
60
|
+
var element = this.markerOption.element;
|
|
61
|
+
// this.sceneSerive.getSceneContainer().appendChild(element as HTMLElement);
|
|
76
62
|
this.mapsService.getMarkerContainer().appendChild(element);
|
|
77
63
|
this.registerMarkerEvent(element);
|
|
78
64
|
this.mapsService.on('camerachange', this.update); // 注册高德1.x 的地图事件监听
|
|
79
|
-
|
|
80
65
|
this.update();
|
|
81
66
|
this.added = true;
|
|
82
67
|
this.emit('added');
|
|
@@ -91,37 +76,30 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
91
76
|
this.mapsService.off('moveend', this.update);
|
|
92
77
|
this.mapsService.off('camerachange', this.update);
|
|
93
78
|
}
|
|
94
|
-
|
|
95
79
|
this.unRegisterMarkerEvent();
|
|
96
80
|
this.removeAllListeners();
|
|
97
81
|
var element = this.markerOption.element;
|
|
98
|
-
|
|
99
82
|
if (element) {
|
|
100
83
|
DOM.remove(element);
|
|
101
84
|
}
|
|
102
|
-
|
|
103
85
|
if (this.popup) {
|
|
104
86
|
this.popup.remove();
|
|
105
87
|
}
|
|
106
|
-
|
|
107
88
|
return this;
|
|
108
89
|
}
|
|
109
90
|
}, {
|
|
110
91
|
key: "setLnglat",
|
|
111
92
|
value: function setLnglat(lngLat) {
|
|
112
93
|
this.lngLat = lngLat;
|
|
113
|
-
|
|
114
94
|
if (Array.isArray(lngLat)) {
|
|
115
95
|
this.lngLat = {
|
|
116
96
|
lng: lngLat[0],
|
|
117
97
|
lat: lngLat[1]
|
|
118
98
|
};
|
|
119
99
|
}
|
|
120
|
-
|
|
121
100
|
if (this.popup) {
|
|
122
101
|
this.popup.setLnglat(this.lngLat);
|
|
123
102
|
}
|
|
124
|
-
|
|
125
103
|
this.update();
|
|
126
104
|
return this;
|
|
127
105
|
}
|
|
@@ -139,20 +117,16 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
139
117
|
key: "setElement",
|
|
140
118
|
value: function setElement(el) {
|
|
141
119
|
var _this2 = this;
|
|
142
|
-
|
|
143
120
|
if (!this.added) {
|
|
144
121
|
this.once('added', function () {
|
|
145
122
|
_this2.setElement(el);
|
|
146
123
|
});
|
|
147
124
|
return this;
|
|
148
125
|
}
|
|
149
|
-
|
|
150
126
|
var element = this.markerOption.element;
|
|
151
|
-
|
|
152
127
|
if (element) {
|
|
153
128
|
DOM.remove(element);
|
|
154
129
|
}
|
|
155
|
-
|
|
156
130
|
this.markerOption.element = el;
|
|
157
131
|
this.init();
|
|
158
132
|
this.mapsService.getMarkerContainer().appendChild(el);
|
|
@@ -164,61 +138,49 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
164
138
|
key: "openPopup",
|
|
165
139
|
value: function openPopup() {
|
|
166
140
|
var _this3 = this;
|
|
167
|
-
|
|
168
141
|
if (!this.added) {
|
|
169
142
|
this.once('added', function () {
|
|
170
143
|
_this3.openPopup();
|
|
171
144
|
});
|
|
172
145
|
return this;
|
|
173
146
|
}
|
|
174
|
-
|
|
175
147
|
var popup = this.popup;
|
|
176
|
-
|
|
177
148
|
if (!popup) {
|
|
178
149
|
return this;
|
|
179
150
|
}
|
|
180
|
-
|
|
181
151
|
if (!popup.isOpen()) {
|
|
182
152
|
popup.addTo(this.scene);
|
|
183
153
|
}
|
|
184
|
-
|
|
185
154
|
return this;
|
|
186
155
|
}
|
|
187
156
|
}, {
|
|
188
157
|
key: "closePopup",
|
|
189
158
|
value: function closePopup() {
|
|
190
159
|
var _this4 = this;
|
|
191
|
-
|
|
192
160
|
if (!this.added) {
|
|
193
161
|
this.once('added', function () {
|
|
194
162
|
_this4.closePopup();
|
|
195
163
|
});
|
|
196
164
|
}
|
|
197
|
-
|
|
198
165
|
var popup = this.popup;
|
|
199
|
-
|
|
200
166
|
if (popup) {
|
|
201
167
|
popup.remove();
|
|
202
168
|
}
|
|
203
|
-
|
|
204
169
|
return this;
|
|
205
170
|
}
|
|
206
171
|
}, {
|
|
207
172
|
key: "setPopup",
|
|
208
173
|
value: function setPopup(popup) {
|
|
209
174
|
this.popup = popup;
|
|
210
|
-
|
|
211
175
|
if (this.lngLat) {
|
|
212
176
|
this.popup.setLnglat(this.lngLat);
|
|
213
177
|
}
|
|
214
|
-
|
|
215
178
|
return this;
|
|
216
179
|
}
|
|
217
180
|
}, {
|
|
218
181
|
key: "togglePopup",
|
|
219
182
|
value: function togglePopup() {
|
|
220
183
|
var popup = this.popup;
|
|
221
|
-
|
|
222
184
|
if (!popup) {
|
|
223
185
|
return this;
|
|
224
186
|
} else if (popup.isOpen()) {
|
|
@@ -226,7 +188,6 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
226
188
|
} else {
|
|
227
189
|
popup.addTo(this.scene);
|
|
228
190
|
}
|
|
229
|
-
|
|
230
191
|
return this;
|
|
231
192
|
}
|
|
232
193
|
}, {
|
|
@@ -238,8 +199,9 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
238
199
|
key: "getOffset",
|
|
239
200
|
value: function getOffset() {
|
|
240
201
|
return this.markerOption.offsets;
|
|
241
|
-
}
|
|
202
|
+
}
|
|
242
203
|
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
243
205
|
}, {
|
|
244
206
|
key: "setDraggable",
|
|
245
207
|
value: function setDraggable(draggable) {
|
|
@@ -266,19 +228,18 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
266
228
|
if (!this.mapsService) {
|
|
267
229
|
return;
|
|
268
230
|
}
|
|
269
|
-
|
|
270
231
|
var _this$markerOption = this.markerOption,
|
|
271
|
-
|
|
272
|
-
|
|
232
|
+
element = _this$markerOption.element,
|
|
233
|
+
anchor = _this$markerOption.anchor;
|
|
273
234
|
this.updatePosition();
|
|
274
235
|
DOM.setTransform(element, "".concat(anchorTranslate[anchor]));
|
|
275
|
-
}
|
|
236
|
+
}
|
|
276
237
|
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
277
239
|
}, {
|
|
278
240
|
key: "onMapClick",
|
|
279
241
|
value: function onMapClick(e) {
|
|
280
242
|
var element = this.markerOption.element;
|
|
281
|
-
|
|
282
243
|
if (this.popup && element) {
|
|
283
244
|
this.togglePopup();
|
|
284
245
|
}
|
|
@@ -299,49 +260,40 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
299
260
|
if (!this.mapsService) {
|
|
300
261
|
return;
|
|
301
262
|
}
|
|
302
|
-
|
|
303
263
|
var _this$markerOption2 = this.markerOption,
|
|
304
|
-
|
|
305
|
-
|
|
264
|
+
element = _this$markerOption2.element,
|
|
265
|
+
offsets = _this$markerOption2.offsets;
|
|
306
266
|
var _this$lngLat = this.lngLat,
|
|
307
|
-
|
|
308
|
-
|
|
267
|
+
lng = _this$lngLat.lng,
|
|
268
|
+
lat = _this$lngLat.lat;
|
|
309
269
|
var pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
310
|
-
|
|
311
270
|
if (element) {
|
|
312
271
|
element.style.display = 'block';
|
|
313
272
|
element.style.whiteSpace = 'nowrap';
|
|
314
|
-
|
|
315
273
|
var _ref = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize(),
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
274
|
+
containerHeight = _ref.containerHeight,
|
|
275
|
+
containerWidth = _ref.containerWidth,
|
|
276
|
+
bounds = _ref.bounds;
|
|
320
277
|
if (!bounds) {
|
|
321
278
|
return;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
279
|
+
}
|
|
280
|
+
// 当前可视区域包含跨日界线
|
|
325
281
|
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
|
326
282
|
if (pos.x > containerWidth) {
|
|
327
283
|
// 日界线右侧点左移
|
|
328
284
|
var newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
|
|
329
285
|
pos.x = newPos.x;
|
|
330
286
|
}
|
|
331
|
-
|
|
332
287
|
if (pos.x < 0) {
|
|
333
288
|
// 日界线左侧点右移
|
|
334
289
|
var _newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
|
|
335
|
-
|
|
336
290
|
pos.x = _newPos.x;
|
|
337
291
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
292
|
+
}
|
|
293
|
+
// 不在当前可视区域内隐藏点
|
|
341
294
|
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
|
|
342
295
|
element.style.display = 'none';
|
|
343
296
|
}
|
|
344
|
-
|
|
345
297
|
element.style.left = pos.x + offsets[0] + 'px';
|
|
346
298
|
element.style.top = pos.y - offsets[1] + 'px';
|
|
347
299
|
}
|
|
@@ -350,12 +302,10 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
350
302
|
key: "init",
|
|
351
303
|
value: function init() {
|
|
352
304
|
var _this5 = this;
|
|
353
|
-
|
|
354
305
|
var element = this.markerOption.element;
|
|
355
306
|
var _this$markerOption3 = this.markerOption,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
307
|
+
color = _this$markerOption3.color,
|
|
308
|
+
anchor = _this$markerOption3.anchor;
|
|
359
309
|
if (!element) {
|
|
360
310
|
this.defaultMarker = true;
|
|
361
311
|
element = DOM.create('div');
|
|
@@ -371,14 +321,12 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
371
321
|
svg.appendChild(path);
|
|
372
322
|
element.appendChild(svg);
|
|
373
323
|
}
|
|
374
|
-
|
|
375
324
|
DOM.addClass(element, 'l7-marker');
|
|
376
|
-
Object.keys(this.markerOption.style || {}).forEach(
|
|
325
|
+
Object.keys(this.markerOption.style || {}).forEach(
|
|
326
|
+
// @ts-ignore
|
|
377
327
|
function (key) {
|
|
378
328
|
var _this5$markerOption, _this5$markerOption2;
|
|
379
|
-
|
|
380
329
|
var value = ((_this5$markerOption = _this5.markerOption) === null || _this5$markerOption === void 0 ? void 0 : _this5$markerOption.style) && ((_this5$markerOption2 = _this5.markerOption) === null || _this5$markerOption2 === void 0 ? void 0 : _this5$markerOption2.style[key]);
|
|
381
|
-
|
|
382
330
|
if (element) {
|
|
383
331
|
// @ts-ignore
|
|
384
332
|
element.style[key] = value;
|
|
@@ -423,12 +371,10 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
423
371
|
if (!this.mapsService || this.mapsService.version !== 'GAODE2.x') {
|
|
424
372
|
return;
|
|
425
373
|
}
|
|
426
|
-
|
|
427
|
-
if (!isPC() && isiOS) {
|
|
374
|
+
if (!isPC()) {
|
|
428
375
|
if (e.type === 'touchstart') {
|
|
429
376
|
this.touchStartTime = Date.now();
|
|
430
377
|
}
|
|
431
|
-
|
|
432
378
|
if (e.type === 'touchend' && Date.now() - this.touchStartTime < 300) {
|
|
433
379
|
this.emit('click', {
|
|
434
380
|
target: e,
|
|
@@ -437,22 +383,22 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
437
383
|
});
|
|
438
384
|
}
|
|
439
385
|
}
|
|
440
|
-
}
|
|
386
|
+
}
|
|
441
387
|
|
|
388
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
442
389
|
}, {
|
|
443
390
|
key: "addDragHandler",
|
|
444
391
|
value: function addDragHandler(e) {
|
|
445
392
|
return null;
|
|
446
|
-
}
|
|
393
|
+
}
|
|
447
394
|
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
448
396
|
}, {
|
|
449
397
|
key: "onUp",
|
|
450
398
|
value: function onUp(e) {
|
|
451
399
|
throw new Error('Method not implemented.');
|
|
452
400
|
}
|
|
453
401
|
}]);
|
|
454
|
-
|
|
455
402
|
return Marker;
|
|
456
403
|
}(EventEmitter);
|
|
457
|
-
|
|
458
404
|
export { Marker as default };
|