@antv/l7-component 2.21.1 → 2.21.2

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.
Files changed (82) hide show
  1. package/es/assets/iconfont/iconfont.js +6 -6
  2. package/es/constants/index.js +2 -2
  3. package/es/control/baseControl/buttonControl.js +109 -144
  4. package/es/control/baseControl/control.js +212 -258
  5. package/es/control/baseControl/popperControl.js +67 -95
  6. package/es/control/baseControl/selectControl.js +132 -178
  7. package/es/control/exportImage.js +59 -142
  8. package/es/control/fullscreen.js +69 -100
  9. package/es/control/geoLocate.js +37 -84
  10. package/es/control/layerSwitch.js +111 -154
  11. package/es/control/logo.js +43 -69
  12. package/es/control/mapTheme.js +57 -98
  13. package/es/control/mouseLocation.js +37 -69
  14. package/es/control/scale.js +107 -135
  15. package/es/control/swipe.js +297 -389
  16. package/es/control/zoom.js +80 -112
  17. package/es/css/index.css +10 -7
  18. package/es/index.js +667 -1
  19. package/es/marker-layer.js +275 -326
  20. package/es/marker.js +394 -446
  21. package/es/popup/layerPopup.js +277 -321
  22. package/es/popup/popup.js +422 -482
  23. package/es/utils/anchor.js +6 -6
  24. package/es/utils/icon.js +4 -4
  25. package/es/utils/popper.js +180 -196
  26. package/es/utils/screenfull.js +29 -51
  27. package/lib/assets/iconfont/iconfont.js +6 -6
  28. package/lib/constants/index.d.ts +60 -0
  29. package/lib/constants/index.js +2 -2
  30. package/lib/control/baseControl/buttonControl.d.ts +60 -0
  31. package/lib/control/baseControl/buttonControl.js +110 -143
  32. package/lib/control/baseControl/control.d.ts +112 -0
  33. package/lib/control/baseControl/control.js +213 -257
  34. package/lib/control/baseControl/index.d.ts +4 -0
  35. package/lib/control/baseControl/index.js +5 -5
  36. package/lib/control/baseControl/popperControl.d.ts +28 -0
  37. package/lib/control/baseControl/popperControl.js +68 -94
  38. package/lib/control/baseControl/selectControl.d.ts +53 -0
  39. package/lib/control/baseControl/selectControl.js +133 -177
  40. package/lib/control/exportImage.d.ts +19 -0
  41. package/lib/control/exportImage.js +60 -141
  42. package/lib/control/fullscreen.d.ts +20 -0
  43. package/lib/control/fullscreen.js +70 -99
  44. package/lib/control/geoLocate.d.ts +17 -0
  45. package/lib/control/geoLocate.js +38 -83
  46. package/lib/control/layerSwitch.d.ts +27 -0
  47. package/lib/control/layerSwitch.js +112 -153
  48. package/lib/control/logo.d.ts +14 -0
  49. package/lib/control/logo.js +44 -69
  50. package/lib/control/mapTheme.d.ts +11 -0
  51. package/lib/control/mapTheme.js +58 -97
  52. package/lib/control/mouseLocation.d.ts +16 -0
  53. package/lib/control/mouseLocation.js +38 -68
  54. package/lib/control/scale.d.ts +35 -0
  55. package/lib/control/scale.js +108 -134
  56. package/lib/control/swipe.d.ts +66 -0
  57. package/lib/control/swipe.js +298 -388
  58. package/lib/control/zoom.d.ts +39 -0
  59. package/lib/control/zoom.js +81 -111
  60. package/lib/css/index.css +10 -7
  61. package/lib/index.d.ts +19 -0
  62. package/lib/index.js +683 -17
  63. package/lib/interface.d.ts +18 -0
  64. package/lib/marker-layer.d.ts +55 -0
  65. package/lib/marker-layer.js +277 -324
  66. package/lib/marker.d.ts +58 -0
  67. package/lib/marker.js +395 -445
  68. package/lib/popup/layerPopup.d.ts +99 -0
  69. package/lib/popup/layerPopup.js +278 -320
  70. package/lib/popup/popup.d.ts +142 -0
  71. package/lib/popup/popup.js +423 -481
  72. package/lib/utils/anchor.d.ts +22 -0
  73. package/lib/utils/anchor.js +6 -6
  74. package/lib/utils/icon.d.ts +1 -0
  75. package/lib/utils/icon.js +6 -5
  76. package/lib/utils/popper.d.ts +76 -0
  77. package/lib/utils/popper.js +184 -196
  78. package/lib/utils/screenfull.d.ts +2 -0
  79. package/lib/utils/screenfull.js +29 -52
  80. package/package.json +16 -20
  81. package/CHANGELOG.md +0 -325
  82. package/LICENSE.md +0 -21
package/lib/marker.js CHANGED
@@ -6,514 +6,464 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
10
  var _l7Utils = require("@antv/l7-utils");
17
11
  var _eventemitter = require("eventemitter3");
18
- 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); }; }
19
- 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; } }
20
12
  // marker 支持 dragger 未完成
21
- var Marker = exports.default = /*#__PURE__*/function (_EventEmitter) {
22
- (0, _inherits2.default)(Marker, _EventEmitter);
23
- var _super = _createSuper(Marker);
24
- function Marker(option) {
25
- var _this;
26
- (0, _classCallCheck2.default)(this, Marker);
27
- _this = _super.call(this);
28
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "added", false);
29
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preLngLat", {
13
+ class Marker extends _eventemitter.EventEmitter {
14
+ // tslint:disable-next-line: no-empty
15
+ getMarkerLayerContainerSize() {}
16
+ constructor(option) {
17
+ super();
18
+ (0, _defineProperty2.default)(this, "markerOption", void 0);
19
+ (0, _defineProperty2.default)(this, "popup", void 0);
20
+ (0, _defineProperty2.default)(this, "mapsService", void 0);
21
+ (0, _defineProperty2.default)(this, "lngLat", void 0);
22
+ (0, _defineProperty2.default)(this, "scene", void 0);
23
+ (0, _defineProperty2.default)(this, "added", false);
24
+ (0, _defineProperty2.default)(this, "preLngLat", {
30
25
  lng: 0,
31
26
  lat: 0
32
27
  });
33
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMarkerDragStart", function (e) {
34
- var mapContainer = _this.mapsService.getContainer();
28
+ (0, _defineProperty2.default)(this, "onMarkerDragStart", e => {
29
+ const mapContainer = this.mapsService.getContainer();
35
30
  if (!mapContainer) {
36
31
  return;
37
32
  }
38
- _this.mapsService.setMapStatus({
33
+ this.mapsService.setMapStatus({
39
34
  dragEnable: false,
40
35
  zoomEnable: false
41
36
  });
42
- var _ref = mapContainer.getClientRects()[0],
43
- containerX = _ref.left,
44
- containerY = _ref.top;
45
- var clickX = e.x,
46
- clickY = e.y;
47
- _this.preLngLat = _this.mapsService.containerToLngLat([clickX - containerX, clickY - containerY]);
48
- _this.mapsService.on('mousemove', _this.onMarkerDragMove);
49
- document.addEventListener('mouseup', _this.onMarkerDragEnd);
50
- _this.emit('dragstart', _this.lngLat);
37
+ const {
38
+ left: containerX,
39
+ top: containerY
40
+ } = mapContainer.getClientRects()[0];
41
+ const {
42
+ x: clickX,
43
+ y: clickY
44
+ } = e;
45
+ this.preLngLat = this.mapsService.containerToLngLat([clickX - containerX, clickY - containerY]);
46
+ this.mapsService.on('mousemove', this.onMarkerDragMove);
47
+ document.addEventListener('mouseup', this.onMarkerDragEnd);
48
+ this.emit('dragstart', this.lngLat);
51
49
  });
52
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMarkerDragMove", function (e) {
53
- var _this$preLngLat = _this.preLngLat,
54
- preLng = _this$preLngLat.lng,
55
- preLat = _this$preLngLat.lat;
56
- var _e$lnglat = e.lnglat,
57
- curLng = _e$lnglat.lng,
58
- curLat = _e$lnglat.lat;
59
- var newLngLat = {
60
- lng: _this.lngLat.lng + curLng - preLng,
61
- lat: _this.lngLat.lat + curLat - preLat
50
+ (0, _defineProperty2.default)(this, "onMarkerDragMove", e => {
51
+ const {
52
+ lng: preLng,
53
+ lat: preLat
54
+ } = this.preLngLat;
55
+ const {
56
+ lng: curLng,
57
+ lat: curLat
58
+ } = e.lnglat;
59
+ const newLngLat = {
60
+ lng: this.lngLat.lng + curLng - preLng,
61
+ lat: this.lngLat.lat + curLat - preLat
62
62
  };
63
- _this.setLnglat(newLngLat);
64
- _this.preLngLat = e.lnglat;
65
- _this.emit('dragging', newLngLat);
63
+ this.setLnglat(newLngLat);
64
+ this.preLngLat = e.lnglat;
65
+ this.emit('dragging', newLngLat);
66
66
  });
67
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMarkerDragEnd", function () {
68
- _this.mapsService.setMapStatus({
67
+ (0, _defineProperty2.default)(this, "onMarkerDragEnd", () => {
68
+ this.mapsService.setMapStatus({
69
69
  dragEnable: true,
70
70
  zoomEnable: true
71
71
  });
72
- _this.mapsService.off('mousemove', _this.onMarkerDragMove);
73
- document.removeEventListener('mouseup', _this.onMarkerDragEnd);
74
- _this.emit('dragend', _this.lngLat);
72
+ this.mapsService.off('mousemove', this.onMarkerDragMove);
73
+ document.removeEventListener('mouseup', this.onMarkerDragEnd);
74
+ this.emit('dragend', this.lngLat);
75
75
  });
76
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventHandle", function (e) {
77
- _this.polyfillEvent(e);
78
- _this.emit(e.type, {
76
+ (0, _defineProperty2.default)(this, "eventHandle", e => {
77
+ this.polyfillEvent(e);
78
+ this.emit(e.type, {
79
79
  target: e,
80
- data: _this.markerOption.extData,
81
- lngLat: _this.lngLat
80
+ data: this.markerOption.extData,
81
+ lngLat: this.lngLat
82
82
  });
83
83
  });
84
- _this.markerOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault()), option);
85
- (0, _l7Utils.bindAll)(['update', 'onMove', 'onMapClick', 'updatePositionWhenZoom'], (0, _assertThisInitialized2.default)(_this));
86
- _this.init();
87
- return _this;
84
+ /**
85
+ * 高德 2.x 使用了 fastClick.js 避免延迟,导致 IOS 移动端的 click 事件不会正常触发,需要手动触发
86
+ * @param e
87
+ */
88
+ (0, _defineProperty2.default)(this, "touchStartTime", void 0);
89
+ this.markerOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.getDefault()), option);
90
+ (0, _l7Utils.bindAll)(['update', 'onMove', 'onMapClick', 'updatePositionWhenZoom'], this);
91
+ this.init();
88
92
  }
89
- (0, _createClass2.default)(Marker, [{
90
- key: "getMarkerLayerContainerSize",
91
- value:
92
- // tslint:disable-next-line: no-empty
93
- function getMarkerLayerContainerSize() {}
94
- }, {
95
- key: "getDefault",
96
- value: function getDefault() {
97
- return {
98
- element: undefined,
99
- // DOM element
100
- anchor: _l7Utils.anchorType.BOTTOM,
101
- offsets: [0, 0],
102
- color: '#5B8FF9',
103
- draggable: false
104
- };
105
- }
106
- }, {
107
- key: "addTo",
108
- value: function addTo(scene) {
109
- this.scene = scene;
110
- this.mapsService = scene.mapService;
111
- var element = this.markerOption.element;
112
- this.mapsService.getMarkerContainer().appendChild(element);
113
- this.registerMarkerEvent(element);
114
- this.mapsService.on('camerachange', this.update); // 注册高德1.x 的地图事件监听
115
- this.update();
116
- this.updateDraggable();
117
- this.added = true;
118
- this.emit('added');
119
- return this;
120
- }
121
- }, {
122
- key: "remove",
123
- value: function remove() {
124
- if (this.mapsService) {
125
- this.mapsService.off('click', this.onMapClick);
126
- this.mapsService.off('move', this.update);
127
- this.mapsService.off('moveend', this.update);
128
- this.mapsService.off('camerachange', this.update);
129
- }
130
- this.unRegisterMarkerEvent();
131
- this.removeAllListeners();
132
- var element = this.markerOption.element;
133
- if (element) {
134
- _l7Utils.DOM.remove(element);
135
- }
136
- if (this.popup) {
137
- this.popup.remove();
138
- }
139
- return this;
93
+ getDefault() {
94
+ return {
95
+ element: undefined,
96
+ // DOM element
97
+ anchor: _l7Utils.anchorType.BOTTOM,
98
+ offsets: [0, 0],
99
+ color: '#5B8FF9',
100
+ draggable: false
101
+ };
102
+ }
103
+ addTo(scene) {
104
+ this.scene = scene;
105
+ this.mapsService = scene.mapService;
106
+ const {
107
+ element
108
+ } = this.markerOption;
109
+ this.mapsService.getMarkerContainer().appendChild(element);
110
+ this.registerMarkerEvent(element);
111
+ this.mapsService.on('camerachange', this.update); // 注册高德1.x 的地图事件监听
112
+ this.update();
113
+ this.updateDraggable();
114
+ this.added = true;
115
+ this.emit('added');
116
+ return this;
117
+ }
118
+ remove() {
119
+ if (this.mapsService) {
120
+ this.mapsService.off('click', this.onMapClick);
121
+ this.mapsService.off('move', this.update);
122
+ this.mapsService.off('moveend', this.update);
123
+ this.mapsService.off('camerachange', this.update);
140
124
  }
141
- }, {
142
- key: "setLnglat",
143
- value: function setLnglat(lngLat) {
144
- this.lngLat = lngLat;
145
- if (Array.isArray(lngLat)) {
146
- this.lngLat = {
147
- lng: lngLat[0],
148
- lat: lngLat[1]
149
- };
150
- }
151
- if (this.popup) {
152
- this.popup.setLnglat(this.lngLat);
153
- }
154
- this.update();
155
- return this;
125
+ this.unRegisterMarkerEvent();
126
+ this.removeAllListeners();
127
+ const {
128
+ element
129
+ } = this.markerOption;
130
+ if (element) {
131
+ _l7Utils.DOM.remove(element);
156
132
  }
157
- }, {
158
- key: "getLnglat",
159
- value: function getLnglat() {
160
- return this.lngLat;
133
+ if (this.popup) {
134
+ this.popup.remove();
161
135
  }
162
- }, {
163
- key: "getElement",
164
- value: function getElement() {
165
- return this.markerOption.element;
136
+ return this;
137
+ }
138
+ setLnglat(lngLat) {
139
+ this.lngLat = lngLat;
140
+ if (Array.isArray(lngLat)) {
141
+ this.lngLat = {
142
+ lng: lngLat[0],
143
+ lat: lngLat[1]
144
+ };
166
145
  }
167
- }, {
168
- key: "setElement",
169
- value: function setElement(el) {
170
- var _this2 = this;
171
- if (!this.added) {
172
- this.once('added', function () {
173
- _this2.setElement(el);
174
- });
175
- return this;
176
- }
177
- var element = this.markerOption.element;
178
- if (element) {
179
- _l7Utils.DOM.remove(element);
180
- }
181
- this.markerOption.element = el;
182
- this.init();
183
- this.mapsService.getMarkerContainer().appendChild(el);
184
- this.registerMarkerEvent(el);
185
- this.updateDraggable();
186
- this.update();
187
- return this;
146
+ if (this.popup) {
147
+ this.popup.setLnglat(this.lngLat);
188
148
  }
189
- }, {
190
- key: "openPopup",
191
- value: function openPopup() {
192
- var _this3 = this;
193
- if (!this.added) {
194
- this.once('added', function () {
195
- _this3.openPopup();
196
- });
197
- return this;
198
- }
199
- var popup = this.popup;
200
- if (!popup) {
201
- return this;
202
- }
203
- if (!popup.isOpen()) {
204
- popup.addTo(this.scene);
205
- }
149
+ this.update();
150
+ return this;
151
+ }
152
+ getLnglat() {
153
+ return this.lngLat;
154
+ }
155
+ getElement() {
156
+ return this.markerOption.element;
157
+ }
158
+ setElement(el) {
159
+ if (!this.added) {
160
+ this.once('added', () => {
161
+ this.setElement(el);
162
+ });
206
163
  return this;
207
164
  }
208
- }, {
209
- key: "closePopup",
210
- value: function closePopup() {
211
- var _this4 = this;
212
- if (!this.added) {
213
- this.once('added', function () {
214
- _this4.closePopup();
215
- });
216
- }
217
- var popup = this.popup;
218
- if (popup) {
219
- popup.remove();
220
- }
221
- return this;
165
+ const {
166
+ element
167
+ } = this.markerOption;
168
+ if (element) {
169
+ _l7Utils.DOM.remove(element);
222
170
  }
223
- }, {
224
- key: "setPopup",
225
- value: function setPopup(popup) {
226
- this.popup = popup;
227
- if (this.lngLat) {
228
- this.popup.setLnglat(this.lngLat);
229
- }
171
+ this.markerOption.element = el;
172
+ this.init();
173
+ this.mapsService.getMarkerContainer().appendChild(el);
174
+ this.registerMarkerEvent(el);
175
+ this.updateDraggable();
176
+ this.update();
177
+ return this;
178
+ }
179
+ openPopup() {
180
+ if (!this.added) {
181
+ this.once('added', () => {
182
+ this.openPopup();
183
+ });
230
184
  return this;
231
185
  }
232
- }, {
233
- key: "togglePopup",
234
- value: function togglePopup() {
235
- var popup = this.popup;
236
- if (!popup) {
237
- return this;
238
- } else if (popup.isOpen()) {
239
- popup.remove();
240
- } else {
241
- popup.addTo(this.scene);
242
- }
186
+ const popup = this.popup;
187
+ if (!popup) {
243
188
  return this;
244
189
  }
245
- }, {
246
- key: "getPopup",
247
- value: function getPopup() {
248
- return this.popup;
190
+ if (!popup.isOpen()) {
191
+ popup.addTo(this.scene);
249
192
  }
250
- }, {
251
- key: "getOffset",
252
- value: function getOffset() {
253
- return this.markerOption.offsets;
193
+ return this;
194
+ }
195
+ closePopup() {
196
+ if (!this.added) {
197
+ this.once('added', () => {
198
+ this.closePopup();
199
+ });
254
200
  }
255
- }, {
256
- key: "setDraggable",
257
- value: function setDraggable(draggable) {
258
- this.markerOption.draggable = draggable;
259
- this.updateDraggable();
201
+ const popup = this.popup;
202
+ if (popup) {
203
+ popup.remove();
260
204
  }
261
- }, {
262
- key: "getDraggable",
263
- value: function getDraggable() {
264
- return this.markerOption.draggable;
205
+ return this;
206
+ }
207
+ setPopup(popup) {
208
+ this.popup = popup;
209
+ if (this.lngLat) {
210
+ this.popup.setLnglat(this.lngLat);
265
211
  }
266
- }, {
267
- key: "getExtData",
268
- value: function getExtData() {
269
- return this.markerOption.extData;
212
+ return this;
213
+ }
214
+ togglePopup() {
215
+ const popup = this.popup;
216
+ if (!popup) {
217
+ return this;
218
+ } else if (popup.isOpen()) {
219
+ popup.remove();
220
+ } else {
221
+ popup.addTo(this.scene);
270
222
  }
271
- }, {
272
- key: "setExtData",
273
- value: function setExtData(data) {
274
- this.markerOption.extData = data;
223
+ return this;
224
+ }
225
+ getPopup() {
226
+ return this.popup;
227
+ }
228
+ getOffset() {
229
+ return this.markerOption.offsets;
230
+ }
231
+ setDraggable(draggable) {
232
+ this.markerOption.draggable = draggable;
233
+ this.updateDraggable();
234
+ }
235
+ getDraggable() {
236
+ return this.markerOption.draggable;
237
+ }
238
+ getExtData() {
239
+ return this.markerOption.extData;
240
+ }
241
+ setExtData(data) {
242
+ this.markerOption.extData = data;
243
+ }
244
+ update() {
245
+ if (!this.mapsService) {
246
+ return;
275
247
  }
276
- }, {
277
- key: "update",
278
- value: function update() {
279
- if (!this.mapsService) {
280
- return;
281
- }
282
- var _this$markerOption = this.markerOption,
283
- element = _this$markerOption.element,
284
- anchor = _this$markerOption.anchor;
285
- this.updatePosition();
286
- _l7Utils.DOM.setTransform(element, "".concat(_l7Utils.anchorTranslate[anchor]));
248
+ const {
249
+ element,
250
+ anchor
251
+ } = this.markerOption;
252
+ this.updatePosition();
253
+ _l7Utils.DOM.setTransform(element, `${_l7Utils.anchorTranslate[anchor]}`);
254
+ }
255
+ //天地图在开始缩放时触发 更新目标位置时添加过渡效果
256
+ updatePositionWhenZoom(ev) {
257
+ if (!this.mapsService) {
258
+ return;
287
259
  }
288
- //天地图在开始缩放时触发 更新目标位置时添加过渡效果
289
- }, {
290
- key: "updatePositionWhenZoom",
291
- value: function updatePositionWhenZoom(ev) {
292
- if (!this.mapsService) {
260
+ const {
261
+ element,
262
+ offsets
263
+ } = this.markerOption;
264
+ const {
265
+ lng,
266
+ lat
267
+ } = this.lngLat;
268
+ if (element) {
269
+ element.style.display = 'block';
270
+ element.style.whiteSpace = 'nowrap';
271
+ const {
272
+ containerHeight,
273
+ containerWidth,
274
+ bounds
275
+ } = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
276
+ if (!bounds) {
293
277
  return;
294
278
  }
295
- var _this$markerOption2 = this.markerOption,
296
- element = _this$markerOption2.element,
297
- offsets = _this$markerOption2.offsets;
298
- var _this$lngLat = this.lngLat,
299
- lng = _this$lngLat.lng,
300
- lat = _this$lngLat.lat;
301
- if (element) {
302
- element.style.display = 'block';
303
- element.style.whiteSpace = 'nowrap';
304
- var _ref2 = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize(),
305
- containerHeight = _ref2.containerHeight,
306
- containerWidth = _ref2.containerWidth,
307
- bounds = _ref2.bounds;
308
- if (!bounds) {
309
- return;
310
- }
311
- var map = ev.map;
312
- var center = ev.center;
313
- var zoom = ev.zoom;
314
- var projectedCenter = map.DE(this.lngLat, zoom, center);
315
- projectedCenter.x = Math.round(projectedCenter.x + offsets[0]);
316
- projectedCenter.y = Math.round(projectedCenter.y - offsets[1]);
317
- // 当前可视区域包含跨日界线
318
- if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
319
- if (projectedCenter.x > containerWidth) {
320
- // 日界线右侧点左移
321
- var newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
322
- projectedCenter.x = newPos.x;
323
- }
324
- if (projectedCenter.x < 0) {
325
- // 日界线左侧点右移
326
- var _newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
327
- projectedCenter.x = _newPos.x;
328
- }
279
+ const map = ev.map;
280
+ const center = ev.center;
281
+ const zoom = ev.zoom;
282
+ const projectedCenter = map.DE(this.lngLat, zoom, center);
283
+ projectedCenter.x = Math.round(projectedCenter.x + offsets[0]);
284
+ projectedCenter.y = Math.round(projectedCenter.y - offsets[1]);
285
+ // 当前可视区域包含跨日界线
286
+ if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
287
+ if (projectedCenter.x > containerWidth) {
288
+ // 日界线右侧点左移
289
+ const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
290
+ projectedCenter.x = newPos.x;
329
291
  }
330
- if (projectedCenter.x > containerWidth || projectedCenter.x < 0 || projectedCenter.y > containerHeight || projectedCenter.y < 0) {
331
- element.style.display = 'none';
292
+ if (projectedCenter.x < 0) {
293
+ // 日界线左侧点右移
294
+ const newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
295
+ projectedCenter.x = newPos.x;
332
296
  }
333
- element.style.left = projectedCenter.x + 'px';
334
- element.style.top = projectedCenter.y + 'px';
335
- element.style.transition = 'left 0.25s cubic-bezier(0,0,0.25,1), top 0.25s cubic-bezier(0,0,0.25,1)';
336
297
  }
337
- }
338
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
339
- }, {
340
- key: "onMapClick",
341
- value: function onMapClick(e) {
342
- var element = this.markerOption.element;
343
- if (this.popup && element) {
344
- this.togglePopup();
298
+ if (projectedCenter.x > containerWidth || projectedCenter.x < 0 || projectedCenter.y > containerHeight || projectedCenter.y < 0) {
299
+ element.style.display = 'none';
345
300
  }
301
+ element.style.left = projectedCenter.x + 'px';
302
+ element.style.top = projectedCenter.y + 'px';
303
+ element.style.transition = 'left 0.25s cubic-bezier(0,0,0.25,1), top 0.25s cubic-bezier(0,0,0.25,1)';
346
304
  }
347
- }, {
348
- key: "getCurrentContainerSize",
349
- value: function getCurrentContainerSize() {
350
- var container = this.mapsService.getContainer();
351
- return {
352
- containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
353
- containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
354
- bounds: this.mapsService.getBounds()
355
- };
305
+ }
306
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
307
+ onMapClick(e) {
308
+ const {
309
+ element
310
+ } = this.markerOption;
311
+ if (this.popup && element) {
312
+ this.togglePopup();
356
313
  }
357
- }, {
358
- key: "updateDraggable",
359
- value: function updateDraggable() {
360
- var element = this.markerOption.element;
361
- element === null || element === void 0 || element.removeEventListener('mousedown', this.onMarkerDragStart);
362
- this.mapsService.off('mousemove', this.onMarkerDragMove);
363
- document.removeEventListener('mouseup', this.onMarkerDragEnd);
364
- if (this.markerOption.draggable) {
365
- element === null || element === void 0 || element.addEventListener('mousedown', this.onMarkerDragStart);
366
- }
314
+ }
315
+ getCurrentContainerSize() {
316
+ const container = this.mapsService.getContainer();
317
+ return {
318
+ containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
319
+ containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
320
+ bounds: this.mapsService.getBounds()
321
+ };
322
+ }
323
+ updateDraggable() {
324
+ const {
325
+ element
326
+ } = this.markerOption;
327
+ element === null || element === void 0 || element.removeEventListener('mousedown', this.onMarkerDragStart);
328
+ this.mapsService.off('mousemove', this.onMarkerDragMove);
329
+ document.removeEventListener('mouseup', this.onMarkerDragEnd);
330
+ if (this.markerOption.draggable) {
331
+ element === null || element === void 0 || element.addEventListener('mousedown', this.onMarkerDragStart);
332
+ }
333
+ }
334
+ updatePosition() {
335
+ if (!this.mapsService) {
336
+ return;
367
337
  }
368
- }, {
369
- key: "updatePosition",
370
- value: function updatePosition() {
371
- if (!this.mapsService) {
338
+ const {
339
+ element,
340
+ offsets
341
+ } = this.markerOption;
342
+ const {
343
+ lng,
344
+ lat
345
+ } = this.lngLat;
346
+ const pos = this.mapsService.lngLatToContainer([lng, lat]);
347
+ if (element) {
348
+ element.style.display = 'block';
349
+ element.style.whiteSpace = 'nowrap';
350
+ const {
351
+ containerHeight,
352
+ containerWidth,
353
+ bounds
354
+ } = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
355
+ if (!bounds) {
372
356
  return;
373
357
  }
374
- var _this$markerOption3 = this.markerOption,
375
- element = _this$markerOption3.element,
376
- offsets = _this$markerOption3.offsets;
377
- var _this$lngLat2 = this.lngLat,
378
- lng = _this$lngLat2.lng,
379
- lat = _this$lngLat2.lat;
380
- var pos = this.mapsService.lngLatToContainer([lng, lat]);
381
- if (element) {
382
- element.style.display = 'block';
383
- element.style.whiteSpace = 'nowrap';
384
- var _ref3 = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize(),
385
- containerHeight = _ref3.containerHeight,
386
- containerWidth = _ref3.containerWidth,
387
- bounds = _ref3.bounds;
388
- if (!bounds) {
389
- return;
390
- }
391
- // 当前可视区域包含跨日界线
392
- if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
393
- if (pos.x > containerWidth) {
394
- // 日界线右侧点左移
395
- var newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
396
- pos.x = newPos.x;
397
- }
398
- if (pos.x < 0) {
399
- // 日界线左侧点右移
400
- var _newPos2 = this.mapsService.lngLatToContainer([lng + 360, lat]);
401
- pos.x = _newPos2.x;
402
- }
358
+ // 当前可视区域包含跨日界线
359
+ if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
360
+ if (pos.x > containerWidth) {
361
+ // 日界线右侧点左移
362
+ const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
363
+ pos.x = newPos.x;
403
364
  }
404
- // 不在当前可视区域内隐藏点
405
- if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
406
- element.style.display = 'none';
365
+ if (pos.x < 0) {
366
+ // 日界线左侧点右移
367
+ const newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
368
+ pos.x = newPos.x;
407
369
  }
408
- element.style.left = pos.x + offsets[0] + 'px';
409
- element.style.top = pos.y - offsets[1] + 'px';
410
370
  }
411
- }
412
- }, {
413
- key: "init",
414
- value: function init() {
415
- var _this5 = this;
416
- var element = this.markerOption.element;
417
- var _this$markerOption4 = this.markerOption,
418
- color = _this$markerOption4.color,
419
- anchor = _this$markerOption4.anchor;
420
- if (!element) {
421
- element = _l7Utils.DOM.create('div');
422
- this.markerOption.element = element;
423
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
424
- svg.setAttributeNS(null, 'display', 'block');
425
- svg.setAttributeNS(null, 'height', '48px');
426
- svg.setAttributeNS(null, 'width', '48px');
427
- svg.setAttributeNS(null, 'viewBox', '0 0 1024 1024');
428
- var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
429
- path.setAttributeNS(null, 'd', 'M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z');
430
- path.setAttributeNS(null, 'fill', color);
431
- svg.appendChild(path);
432
- element.appendChild(svg);
371
+ // 不在当前可视区域内隐藏点
372
+ if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
373
+ element.style.display = 'none';
433
374
  }
434
- _l7Utils.DOM.addClass(element, 'l7-marker');
435
- Object.keys(this.markerOption.style || {}).forEach(
436
- // @ts-ignore
437
- function (key) {
438
- var _this5$markerOption, _this5$markerOption2;
439
- 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]);
440
- if (element) {
441
- // @ts-ignore
442
- element.style[key] = value;
443
- }
444
- });
445
- (0, _l7Utils.applyAnchorClass)(element, anchor, 'marker');
375
+ element.style.left = pos.x + offsets[0] + 'px';
376
+ element.style.top = pos.y - offsets[1] + 'px';
446
377
  }
447
- }, {
448
- key: "registerMarkerEvent",
449
- value: function registerMarkerEvent(element) {
450
- element.addEventListener('click', this.onMapClick);
451
- element.addEventListener('mousemove', this.eventHandle);
452
- element.addEventListener('click', this.eventHandle);
453
- element.addEventListener('mousedown', this.eventHandle);
454
- element.addEventListener('mouseup', this.eventHandle);
455
- element.addEventListener('dblclick', this.eventHandle);
456
- element.addEventListener('contextmenu', this.eventHandle);
457
- element.addEventListener('mouseover', this.eventHandle);
458
- element.addEventListener('mouseout', this.eventHandle);
459
- element.addEventListener('touchstart', this.eventHandle);
460
- element.addEventListener('touchend', this.eventHandle);
378
+ }
379
+ init() {
380
+ let {
381
+ element
382
+ } = this.markerOption;
383
+ const {
384
+ color,
385
+ anchor
386
+ } = this.markerOption;
387
+ if (!element) {
388
+ element = _l7Utils.DOM.create('div');
389
+ this.markerOption.element = element;
390
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
391
+ svg.setAttributeNS(null, 'display', 'block');
392
+ svg.setAttributeNS(null, 'height', '48px');
393
+ svg.setAttributeNS(null, 'width', '48px');
394
+ svg.setAttributeNS(null, 'viewBox', '0 0 1024 1024');
395
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
396
+ path.setAttributeNS(null, 'd', 'M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z');
397
+ path.setAttributeNS(null, 'fill', color);
398
+ svg.appendChild(path);
399
+ element.appendChild(svg);
461
400
  }
462
- }, {
463
- key: "unRegisterMarkerEvent",
464
- value: function unRegisterMarkerEvent() {
465
- var element = this.getElement();
466
- element.removeEventListener('click', this.onMapClick);
467
- element.removeEventListener('mousemove', this.eventHandle);
468
- element.removeEventListener('click', this.eventHandle);
469
- element.removeEventListener('mousedown', this.eventHandle);
470
- element.removeEventListener('mouseup', this.eventHandle);
471
- element.removeEventListener('dblclick', this.eventHandle);
472
- element.removeEventListener('contextmenu', this.eventHandle);
473
- element.removeEventListener('mouseover', this.eventHandle);
474
- element.removeEventListener('mouseout', this.eventHandle);
475
- element.removeEventListener('touchstart', this.eventHandle);
476
- element.removeEventListener('touchend', this.eventHandle);
401
+ _l7Utils.DOM.addClass(element, 'l7-marker');
402
+ Object.keys(this.markerOption.style || {}).forEach(
403
+ // @ts-ignore
404
+ key => {
405
+ var _this$markerOption, _this$markerOption2;
406
+ const value = ((_this$markerOption = this.markerOption) === null || _this$markerOption === void 0 ? void 0 : _this$markerOption.style) && ((_this$markerOption2 = this.markerOption) === null || _this$markerOption2 === void 0 ? void 0 : _this$markerOption2.style[key]);
407
+ if (element) {
408
+ // @ts-ignore
409
+ element.style[key] = value;
410
+ }
411
+ });
412
+ (0, _l7Utils.applyAnchorClass)(element, anchor, 'marker');
413
+ }
414
+ registerMarkerEvent(element) {
415
+ element.addEventListener('click', this.onMapClick);
416
+ element.addEventListener('mousemove', this.eventHandle);
417
+ element.addEventListener('click', this.eventHandle);
418
+ element.addEventListener('mousedown', this.eventHandle);
419
+ element.addEventListener('mouseup', this.eventHandle);
420
+ element.addEventListener('dblclick', this.eventHandle);
421
+ element.addEventListener('contextmenu', this.eventHandle);
422
+ element.addEventListener('mouseover', this.eventHandle);
423
+ element.addEventListener('mouseout', this.eventHandle);
424
+ element.addEventListener('touchstart', this.eventHandle);
425
+ element.addEventListener('touchend', this.eventHandle);
426
+ }
427
+ unRegisterMarkerEvent() {
428
+ const element = this.getElement();
429
+ element.removeEventListener('click', this.onMapClick);
430
+ element.removeEventListener('mousemove', this.eventHandle);
431
+ element.removeEventListener('click', this.eventHandle);
432
+ element.removeEventListener('mousedown', this.eventHandle);
433
+ element.removeEventListener('mouseup', this.eventHandle);
434
+ element.removeEventListener('dblclick', this.eventHandle);
435
+ element.removeEventListener('contextmenu', this.eventHandle);
436
+ element.removeEventListener('mouseover', this.eventHandle);
437
+ element.removeEventListener('mouseout', this.eventHandle);
438
+ element.removeEventListener('touchstart', this.eventHandle);
439
+ element.removeEventListener('touchend', this.eventHandle);
440
+ }
441
+ polyfillEvent(e) {
442
+ if (!this.mapsService || this.mapsService.version !== 'GAODE2.x') {
443
+ return;
477
444
  }
478
- }, {
479
- key: "polyfillEvent",
480
- value:
481
- /**
482
- * 高德 2.x 使用了 fastClick.js 避免延迟,导致 IOS 移动端的 click 事件不会正常触发,需要手动触发
483
- * @param e
484
- */
485
-
486
- function polyfillEvent(e) {
487
- if (!this.mapsService || this.mapsService.version !== 'GAODE2.x') {
488
- return;
445
+ if (!(0, _l7Utils.isPC)()) {
446
+ if (e.type === 'touchstart') {
447
+ this.touchStartTime = Date.now();
489
448
  }
490
- if (!(0, _l7Utils.isPC)()) {
491
- if (e.type === 'touchstart') {
492
- this.touchStartTime = Date.now();
493
- }
494
- if (e.type === 'touchend' && Date.now() - this.touchStartTime < 300) {
495
- this.emit('click', {
496
- target: e,
497
- data: this.markerOption.extData,
498
- lngLat: this.lngLat
499
- });
500
- }
449
+ if (e.type === 'touchend' && Date.now() - this.touchStartTime < 300) {
450
+ this.emit('click', {
451
+ target: e,
452
+ data: this.markerOption.extData,
453
+ lngLat: this.lngLat
454
+ });
501
455
  }
502
456
  }
457
+ }
503
458
 
504
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
505
- }, {
506
- key: "addDragHandler",
507
- value: function addDragHandler(e) {
508
- return null;
509
- }
459
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
460
+ addDragHandler(e) {
461
+ return null;
462
+ }
510
463
 
511
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
512
- }, {
513
- key: "onUp",
514
- value: function onUp(e) {
515
- throw new Error('Method not implemented.');
516
- }
517
- }]);
518
- return Marker;
519
- }(_eventemitter.EventEmitter);
464
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
465
+ onUp(e) {
466
+ throw new Error('Method not implemented.');
467
+ }
468
+ }
469
+ exports.default = Marker;