@antv/l7-component 2.15.1 → 2.15.3
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 +29 -83
- 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 +29 -91
- 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/lib/marker.js
CHANGED
|
@@ -1,53 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
16
|
var _l7Core = require("@antv/l7-core");
|
|
27
|
-
|
|
28
17
|
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
-
|
|
30
18
|
var _eventemitter = require("eventemitter3");
|
|
31
|
-
|
|
32
19
|
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); }; }
|
|
33
|
-
|
|
34
20
|
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; } }
|
|
35
|
-
|
|
36
21
|
// marker 支持 dragger 未完成
|
|
37
22
|
var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
38
23
|
(0, _inherits2.default)(Marker, _EventEmitter);
|
|
39
|
-
|
|
40
24
|
var _super = _createSuper(Marker);
|
|
41
|
-
|
|
42
25
|
function Marker(option) {
|
|
43
26
|
var _this;
|
|
44
|
-
|
|
45
27
|
(0, _classCallCheck2.default)(this, Marker);
|
|
46
28
|
_this = _super.call(this);
|
|
47
29
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "added", false);
|
|
48
30
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventHandle", function (e) {
|
|
49
31
|
_this.polyfillEvent(e);
|
|
50
|
-
|
|
51
32
|
_this.emit(e.type, {
|
|
52
33
|
target: e,
|
|
53
34
|
data: _this.markerOption.extData,
|
|
@@ -56,15 +37,13 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
56
37
|
});
|
|
57
38
|
_this.markerOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault()), option);
|
|
58
39
|
(0, _l7Utils.bindAll)(['update', 'onMove', 'onMapClick'], (0, _assertThisInitialized2.default)(_this));
|
|
59
|
-
|
|
60
40
|
_this.init();
|
|
61
|
-
|
|
62
41
|
return _this;
|
|
63
42
|
}
|
|
64
|
-
|
|
65
43
|
(0, _createClass2.default)(Marker, [{
|
|
66
44
|
key: "getMarkerLayerContainerSize",
|
|
67
|
-
value:
|
|
45
|
+
value:
|
|
46
|
+
// tslint:disable-next-line: no-empty
|
|
68
47
|
function getMarkerLayerContainerSize() {}
|
|
69
48
|
}, {
|
|
70
49
|
key: "getDefault",
|
|
@@ -85,12 +64,11 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
85
64
|
this.scene = scene;
|
|
86
65
|
this.mapsService = scene.get(_l7Core.TYPES.IMapService);
|
|
87
66
|
this.sceneSerive = scene.get(_l7Core.TYPES.ISceneService);
|
|
88
|
-
var element = this.markerOption.element;
|
|
89
|
-
|
|
67
|
+
var element = this.markerOption.element;
|
|
68
|
+
// this.sceneSerive.getSceneContainer().appendChild(element as HTMLElement);
|
|
90
69
|
this.mapsService.getMarkerContainer().appendChild(element);
|
|
91
70
|
this.registerMarkerEvent(element);
|
|
92
71
|
this.mapsService.on('camerachange', this.update); // 注册高德1.x 的地图事件监听
|
|
93
|
-
|
|
94
72
|
this.update();
|
|
95
73
|
this.added = true;
|
|
96
74
|
this.emit('added');
|
|
@@ -105,37 +83,30 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
105
83
|
this.mapsService.off('moveend', this.update);
|
|
106
84
|
this.mapsService.off('camerachange', this.update);
|
|
107
85
|
}
|
|
108
|
-
|
|
109
86
|
this.unRegisterMarkerEvent();
|
|
110
87
|
this.removeAllListeners();
|
|
111
88
|
var element = this.markerOption.element;
|
|
112
|
-
|
|
113
89
|
if (element) {
|
|
114
90
|
_l7Utils.DOM.remove(element);
|
|
115
91
|
}
|
|
116
|
-
|
|
117
92
|
if (this.popup) {
|
|
118
93
|
this.popup.remove();
|
|
119
94
|
}
|
|
120
|
-
|
|
121
95
|
return this;
|
|
122
96
|
}
|
|
123
97
|
}, {
|
|
124
98
|
key: "setLnglat",
|
|
125
99
|
value: function setLnglat(lngLat) {
|
|
126
100
|
this.lngLat = lngLat;
|
|
127
|
-
|
|
128
101
|
if (Array.isArray(lngLat)) {
|
|
129
102
|
this.lngLat = {
|
|
130
103
|
lng: lngLat[0],
|
|
131
104
|
lat: lngLat[1]
|
|
132
105
|
};
|
|
133
106
|
}
|
|
134
|
-
|
|
135
107
|
if (this.popup) {
|
|
136
108
|
this.popup.setLnglat(this.lngLat);
|
|
137
109
|
}
|
|
138
|
-
|
|
139
110
|
this.update();
|
|
140
111
|
return this;
|
|
141
112
|
}
|
|
@@ -153,20 +124,16 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
153
124
|
key: "setElement",
|
|
154
125
|
value: function setElement(el) {
|
|
155
126
|
var _this2 = this;
|
|
156
|
-
|
|
157
127
|
if (!this.added) {
|
|
158
128
|
this.once('added', function () {
|
|
159
129
|
_this2.setElement(el);
|
|
160
130
|
});
|
|
161
131
|
return this;
|
|
162
132
|
}
|
|
163
|
-
|
|
164
133
|
var element = this.markerOption.element;
|
|
165
|
-
|
|
166
134
|
if (element) {
|
|
167
135
|
_l7Utils.DOM.remove(element);
|
|
168
136
|
}
|
|
169
|
-
|
|
170
137
|
this.markerOption.element = el;
|
|
171
138
|
this.init();
|
|
172
139
|
this.mapsService.getMarkerContainer().appendChild(el);
|
|
@@ -178,61 +145,49 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
178
145
|
key: "openPopup",
|
|
179
146
|
value: function openPopup() {
|
|
180
147
|
var _this3 = this;
|
|
181
|
-
|
|
182
148
|
if (!this.added) {
|
|
183
149
|
this.once('added', function () {
|
|
184
150
|
_this3.openPopup();
|
|
185
151
|
});
|
|
186
152
|
return this;
|
|
187
153
|
}
|
|
188
|
-
|
|
189
154
|
var popup = this.popup;
|
|
190
|
-
|
|
191
155
|
if (!popup) {
|
|
192
156
|
return this;
|
|
193
157
|
}
|
|
194
|
-
|
|
195
158
|
if (!popup.isOpen()) {
|
|
196
159
|
popup.addTo(this.scene);
|
|
197
160
|
}
|
|
198
|
-
|
|
199
161
|
return this;
|
|
200
162
|
}
|
|
201
163
|
}, {
|
|
202
164
|
key: "closePopup",
|
|
203
165
|
value: function closePopup() {
|
|
204
166
|
var _this4 = this;
|
|
205
|
-
|
|
206
167
|
if (!this.added) {
|
|
207
168
|
this.once('added', function () {
|
|
208
169
|
_this4.closePopup();
|
|
209
170
|
});
|
|
210
171
|
}
|
|
211
|
-
|
|
212
172
|
var popup = this.popup;
|
|
213
|
-
|
|
214
173
|
if (popup) {
|
|
215
174
|
popup.remove();
|
|
216
175
|
}
|
|
217
|
-
|
|
218
176
|
return this;
|
|
219
177
|
}
|
|
220
178
|
}, {
|
|
221
179
|
key: "setPopup",
|
|
222
180
|
value: function setPopup(popup) {
|
|
223
181
|
this.popup = popup;
|
|
224
|
-
|
|
225
182
|
if (this.lngLat) {
|
|
226
183
|
this.popup.setLnglat(this.lngLat);
|
|
227
184
|
}
|
|
228
|
-
|
|
229
185
|
return this;
|
|
230
186
|
}
|
|
231
187
|
}, {
|
|
232
188
|
key: "togglePopup",
|
|
233
189
|
value: function togglePopup() {
|
|
234
190
|
var popup = this.popup;
|
|
235
|
-
|
|
236
191
|
if (!popup) {
|
|
237
192
|
return this;
|
|
238
193
|
} else if (popup.isOpen()) {
|
|
@@ -240,7 +195,6 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
240
195
|
} else {
|
|
241
196
|
popup.addTo(this.scene);
|
|
242
197
|
}
|
|
243
|
-
|
|
244
198
|
return this;
|
|
245
199
|
}
|
|
246
200
|
}, {
|
|
@@ -252,8 +206,9 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
252
206
|
key: "getOffset",
|
|
253
207
|
value: function getOffset() {
|
|
254
208
|
return this.markerOption.offsets;
|
|
255
|
-
}
|
|
209
|
+
}
|
|
256
210
|
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
257
212
|
}, {
|
|
258
213
|
key: "setDraggable",
|
|
259
214
|
value: function setDraggable(draggable) {
|
|
@@ -280,20 +235,18 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
280
235
|
if (!this.mapsService) {
|
|
281
236
|
return;
|
|
282
237
|
}
|
|
283
|
-
|
|
284
238
|
var _this$markerOption = this.markerOption,
|
|
285
|
-
|
|
286
|
-
|
|
239
|
+
element = _this$markerOption.element,
|
|
240
|
+
anchor = _this$markerOption.anchor;
|
|
287
241
|
this.updatePosition();
|
|
288
|
-
|
|
289
242
|
_l7Utils.DOM.setTransform(element, "".concat(_l7Utils.anchorTranslate[anchor]));
|
|
290
|
-
}
|
|
243
|
+
}
|
|
291
244
|
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
292
246
|
}, {
|
|
293
247
|
key: "onMapClick",
|
|
294
248
|
value: function onMapClick(e) {
|
|
295
249
|
var element = this.markerOption.element;
|
|
296
|
-
|
|
297
250
|
if (this.popup && element) {
|
|
298
251
|
this.togglePopup();
|
|
299
252
|
}
|
|
@@ -314,49 +267,40 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
314
267
|
if (!this.mapsService) {
|
|
315
268
|
return;
|
|
316
269
|
}
|
|
317
|
-
|
|
318
270
|
var _this$markerOption2 = this.markerOption,
|
|
319
|
-
|
|
320
|
-
|
|
271
|
+
element = _this$markerOption2.element,
|
|
272
|
+
offsets = _this$markerOption2.offsets;
|
|
321
273
|
var _this$lngLat = this.lngLat,
|
|
322
|
-
|
|
323
|
-
|
|
274
|
+
lng = _this$lngLat.lng,
|
|
275
|
+
lat = _this$lngLat.lat;
|
|
324
276
|
var pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
325
|
-
|
|
326
277
|
if (element) {
|
|
327
278
|
element.style.display = 'block';
|
|
328
279
|
element.style.whiteSpace = 'nowrap';
|
|
329
|
-
|
|
330
280
|
var _ref = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize(),
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
281
|
+
containerHeight = _ref.containerHeight,
|
|
282
|
+
containerWidth = _ref.containerWidth,
|
|
283
|
+
bounds = _ref.bounds;
|
|
335
284
|
if (!bounds) {
|
|
336
285
|
return;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
286
|
+
}
|
|
287
|
+
// 当前可视区域包含跨日界线
|
|
340
288
|
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
|
341
289
|
if (pos.x > containerWidth) {
|
|
342
290
|
// 日界线右侧点左移
|
|
343
291
|
var newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
|
|
344
292
|
pos.x = newPos.x;
|
|
345
293
|
}
|
|
346
|
-
|
|
347
294
|
if (pos.x < 0) {
|
|
348
295
|
// 日界线左侧点右移
|
|
349
296
|
var _newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
|
|
350
|
-
|
|
351
297
|
pos.x = _newPos.x;
|
|
352
298
|
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
299
|
+
}
|
|
300
|
+
// 不在当前可视区域内隐藏点
|
|
356
301
|
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
|
|
357
302
|
element.style.display = 'none';
|
|
358
303
|
}
|
|
359
|
-
|
|
360
304
|
element.style.left = pos.x + offsets[0] + 'px';
|
|
361
305
|
element.style.top = pos.y - offsets[1] + 'px';
|
|
362
306
|
}
|
|
@@ -365,12 +309,10 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
365
309
|
key: "init",
|
|
366
310
|
value: function init() {
|
|
367
311
|
var _this5 = this;
|
|
368
|
-
|
|
369
312
|
var element = this.markerOption.element;
|
|
370
313
|
var _this$markerOption3 = this.markerOption,
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
314
|
+
color = _this$markerOption3.color,
|
|
315
|
+
anchor = _this$markerOption3.anchor;
|
|
374
316
|
if (!element) {
|
|
375
317
|
this.defaultMarker = true;
|
|
376
318
|
element = _l7Utils.DOM.create('div');
|
|
@@ -386,15 +328,12 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
386
328
|
svg.appendChild(path);
|
|
387
329
|
element.appendChild(svg);
|
|
388
330
|
}
|
|
389
|
-
|
|
390
331
|
_l7Utils.DOM.addClass(element, 'l7-marker');
|
|
391
|
-
|
|
392
|
-
|
|
332
|
+
Object.keys(this.markerOption.style || {}).forEach(
|
|
333
|
+
// @ts-ignore
|
|
393
334
|
function (key) {
|
|
394
335
|
var _this5$markerOption, _this5$markerOption2;
|
|
395
|
-
|
|
396
336
|
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]);
|
|
397
|
-
|
|
398
337
|
if (element) {
|
|
399
338
|
// @ts-ignore
|
|
400
339
|
element.style[key] = value;
|
|
@@ -439,12 +378,10 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
439
378
|
if (!this.mapsService || this.mapsService.version !== 'GAODE2.x') {
|
|
440
379
|
return;
|
|
441
380
|
}
|
|
442
|
-
|
|
443
381
|
if (!(0, _l7Utils.isPC)() && _l7Utils.isiOS) {
|
|
444
382
|
if (e.type === 'touchstart') {
|
|
445
383
|
this.touchStartTime = Date.now();
|
|
446
384
|
}
|
|
447
|
-
|
|
448
385
|
if (e.type === 'touchend' && Date.now() - this.touchStartTime < 300) {
|
|
449
386
|
this.emit('click', {
|
|
450
387
|
target: e,
|
|
@@ -453,14 +390,16 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
453
390
|
});
|
|
454
391
|
}
|
|
455
392
|
}
|
|
456
|
-
}
|
|
393
|
+
}
|
|
457
394
|
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
458
396
|
}, {
|
|
459
397
|
key: "addDragHandler",
|
|
460
398
|
value: function addDragHandler(e) {
|
|
461
399
|
return null;
|
|
462
|
-
}
|
|
400
|
+
}
|
|
463
401
|
|
|
402
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
464
403
|
}, {
|
|
465
404
|
key: "onUp",
|
|
466
405
|
value: function onUp(e) {
|
|
@@ -469,5 +408,4 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
469
408
|
}]);
|
|
470
409
|
return Marker;
|
|
471
410
|
}(_eventemitter.EventEmitter);
|
|
472
|
-
|
|
473
411
|
exports.default = Marker;
|