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