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