@antv/l7-component 2.23.0 → 2.23.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.
package/es/interface.d.ts CHANGED
@@ -15,4 +15,15 @@ export interface IMarkerStyleOption {
15
15
  export interface IMarkerLayerOption {
16
16
  cluster: boolean;
17
17
  clusterOption: Partial<IMarkerStyleOption>;
18
+ /**
19
+ * Default marker options applied to markers added to this layer when not overridden per-marker.
20
+ * Example: { color: '#ff0000', style: { width: '24px', height: '24px' }, className: 'my-marker' }
21
+ */
22
+ markerOption?: Partial<{
23
+ color?: string;
24
+ style?: {
25
+ [key: string]: any;
26
+ };
27
+ className?: string;
28
+ }>;
18
29
  }
@@ -43,6 +43,7 @@ export default class MarkerLayer extends EventEmitter {
43
43
  addMarkers(): void;
44
44
  clear(): void;
45
45
  destroy(): void;
46
+ private updateMarkers;
46
47
  private addPoint;
47
48
  private removePoint;
48
49
  private initCluster;
@@ -56,6 +56,9 @@ export default class MarkerLayer extends EventEmitter {
56
56
  this.mapsService.on('camerachange', this.update); // amap1.x 更新事件
57
57
  this.mapsService.on('viewchange', this.update); // amap2.0 更新事件
58
58
  }
59
+ // 统一由 layer 管理 marker 的位置更新,避免每个 marker 单独注册地图事件
60
+ this.mapsService.on('camerachange', this.updateMarkers.bind(this));
61
+ this.mapsService.on('viewchange', this.updateMarkers.bind(this));
59
62
  this.mapsService.on('camerachange', this.setContainerSize.bind(this)); // amap1.x 更新事件
60
63
  this.mapsService.on('viewchange', this.setContainerSize.bind(this)); // amap2.0 更新事件
61
64
  this.addMarkers();
@@ -85,6 +88,54 @@ export default class MarkerLayer extends EventEmitter {
85
88
  addMarker(marker) {
86
89
  const cluster = this.markerLayerOption.cluster;
87
90
  marker.getMarkerLayerContainerSize = this.getContainerSize.bind(this);
91
+
92
+ // apply default markerOption if provided by layer
93
+ try {
94
+ const mOpt = this.markerLayerOption.markerOption;
95
+ if (mOpt && marker && typeof marker.getElement === 'function') {
96
+ const el = marker.getElement();
97
+ if (el) {
98
+ // apply className
99
+ if (mOpt.className) {
100
+ // DOM helper available
101
+ try {
102
+ DOM.addClass(el, mOpt.className);
103
+ } catch (e) {
104
+ el.className = `${el.className || ''} ${mOpt.className}`.trim();
105
+ }
106
+ }
107
+ // apply style properties
108
+ if (mOpt.style && typeof mOpt.style === 'object') {
109
+ Object.keys(mOpt.style).forEach(k => {
110
+ try {
111
+ // @ts-ignore
112
+ el.style[k] = mOpt.style[k];
113
+ } catch (e) {
114
+ // ignore invalid styles
115
+ }
116
+ });
117
+ }
118
+ // apply color: try find svg path inside marker element and set fill
119
+ if (mOpt.color) {
120
+ try {
121
+ // querySelector can return SVGPathElement; coerce to any for attribute access
122
+ const svgPath = el.querySelector ? el.querySelector('path') : null;
123
+ if (svgPath && typeof svgPath.setAttribute === 'function') {
124
+ svgPath.setAttribute('fill', mOpt.color);
125
+ } else {
126
+ // fallback: set background color
127
+ el.style.background = mOpt.color;
128
+ }
129
+ } catch (e) {
130
+ // ignore
131
+ }
132
+ }
133
+ }
134
+ }
135
+ } catch (err) {
136
+ // be defensive — don't block marker addition on errors applying defaults
137
+ void err;
138
+ }
88
139
  if (cluster) {
89
140
  this.addPoint(marker, this.markers.length);
90
141
  if (this.mapsService) {
@@ -97,11 +148,36 @@ export default class MarkerLayer extends EventEmitter {
97
148
  }
98
149
  }
99
150
  this.markers.push(marker);
151
+
152
+ // if layer has been added to a scene, immediately add marker's element into scene
153
+ // this ensures addMarker works both before and after addTo(scene)
154
+ try {
155
+ if (this.inited && this.scene && typeof marker.addTo === 'function') {
156
+ // When cluster mode is enabled, defer actual DOM mounting of original markers
157
+ // to the clustering render pass so that only cluster markers (or the chosen
158
+ // original marker for single-point clusters) are attached. This prevents
159
+ // duplicate DOM nodes / missing event handlers caused by pre-mounting originals.
160
+ if (!this.markerLayerOption.cluster) {
161
+ marker.addTo(this.scene);
162
+ }
163
+ }
164
+ } catch (e) {
165
+ // defensive: do not break on addTo errors
166
+ void e;
167
+ }
100
168
  }
101
169
  removeMarker(marker) {
102
170
  this.markers.indexOf(marker);
103
171
  const markerIndex = this.markers.indexOf(marker);
104
172
  if (markerIndex > -1) {
173
+ // remove visual element and unbind handlers
174
+ try {
175
+ if (typeof marker.remove === 'function') {
176
+ marker.remove();
177
+ }
178
+ } catch (e) {
179
+ void e;
180
+ }
105
181
  this.markers.splice(markerIndex, 1);
106
182
  if (this.markerLayerOption.cluster) {
107
183
  this.removePoint(markerIndex);
@@ -116,11 +192,27 @@ export default class MarkerLayer extends EventEmitter {
116
192
  * 隐藏 marker 在每个 marker 上单独修改属性而不是在 markerContainer 上修改(在 markerContainer 修改会有用户在场景加载完之前调用失败的问题)
117
193
  */
118
194
  hide() {
119
- this.markers.map(m => {
120
- m.getElement().style.opacity = '0';
195
+ this.markers.forEach(m => {
196
+ try {
197
+ if (typeof m.hide === 'function') {
198
+ m.hide();
199
+ } else {
200
+ m.getElement().style.opacity = '0';
201
+ }
202
+ } catch (e) {
203
+ void e;
204
+ }
121
205
  });
122
- this.clusterMarkers.map(m => {
123
- m.getElement().style.opacity = '0';
206
+ this.clusterMarkers.forEach(m => {
207
+ try {
208
+ if (typeof m.hide === 'function') {
209
+ m.hide();
210
+ } else {
211
+ m.getElement().style.opacity = '0';
212
+ }
213
+ } catch (e) {
214
+ void e;
215
+ }
124
216
  });
125
217
  }
126
218
 
@@ -128,11 +220,27 @@ export default class MarkerLayer extends EventEmitter {
128
220
  * 显示 marker
129
221
  */
130
222
  show() {
131
- this.markers.map(m => {
132
- m.getElement().style.opacity = '1';
223
+ this.markers.forEach(m => {
224
+ try {
225
+ if (typeof m.show === 'function') {
226
+ m.show();
227
+ } else {
228
+ m.getElement().style.opacity = '1';
229
+ }
230
+ } catch (e) {
231
+ void e;
232
+ }
133
233
  });
134
- this.clusterMarkers.map(m => {
135
- m.getElement().style.opacity = '1';
234
+ this.clusterMarkers.forEach(m => {
235
+ try {
236
+ if (typeof m.show === 'function') {
237
+ m.show();
238
+ } else {
239
+ m.getElement().style.opacity = '1';
240
+ }
241
+ } catch (e) {
242
+ void e;
243
+ }
136
244
  });
137
245
  }
138
246
 
@@ -171,6 +279,25 @@ export default class MarkerLayer extends EventEmitter {
171
279
  this.mapsService.off('viewchange', this.update);
172
280
  this.mapsService.off('camerachange', this.setContainerSize.bind(this));
173
281
  this.mapsService.off('viewchange', this.setContainerSize.bind(this));
282
+ this.mapsService.off('camerachange', this.updateMarkers.bind(this));
283
+ this.mapsService.off('viewchange', this.updateMarkers.bind(this));
284
+ }
285
+ updateMarkers() {
286
+ // update positions for both origin markers and cluster markers
287
+ try {
288
+ this.markers.forEach(m => {
289
+ if (m && typeof m.update === 'function') {
290
+ m.update();
291
+ }
292
+ });
293
+ this.clusterMarkers.forEach(m => {
294
+ if (m && typeof m.update === 'function') {
295
+ m.update();
296
+ }
297
+ });
298
+ } catch (e) {
299
+ void e;
300
+ }
174
301
  }
175
302
 
176
303
  // 将marker数据保存在point中
@@ -253,6 +380,27 @@ export default class MarkerLayer extends EventEmitter {
253
380
  }
254
381
  }
255
382
  const marker = this.clusterMarker(feature);
383
+ // attach layer-level re-emission so consumers can listen to cluster marker events
384
+ try {
385
+ // IMarker type may not declare EventEmitter methods; cast to any for runtime attach
386
+ const anyMarker = marker;
387
+ if (anyMarker && typeof anyMarker.on === 'function') {
388
+ anyMarker.on('click', ev => {
389
+ try {
390
+ this.emit('marker:click', {
391
+ marker: anyMarker,
392
+ data: anyMarker.getExtData ? anyMarker.getExtData() : null,
393
+ lngLat: anyMarker.getLnglat ? anyMarker.getLnglat() : null,
394
+ originalEvent: ev
395
+ });
396
+ } catch (e) {
397
+ void e;
398
+ }
399
+ });
400
+ }
401
+ } catch (e) {
402
+ void e;
403
+ }
256
404
  this.clusterMarkers.push(marker);
257
405
  marker.addTo(this.scene);
258
406
  });
@@ -264,16 +412,65 @@ export default class MarkerLayer extends EventEmitter {
264
412
  return this.clusterIndex.getLeaves(clusterId, limit, offset);
265
413
  }
266
414
  clusterMarker(feature) {
415
+ var _feature$properties3, _feature$properties4;
267
416
  const clusterOption = this.markerLayerOption.clusterOption;
268
417
  const {
269
418
  element = this.generateElement.bind(this)
270
419
  } = clusterOption;
420
+
421
+ // determine cluster count
422
+ let pointCount = (_feature$properties3 = feature.properties) === null || _feature$properties3 === void 0 ? void 0 : _feature$properties3.point_count;
423
+ if (pointCount === undefined && (_feature$properties4 = feature.properties) !== null && _feature$properties4 !== void 0 && _feature$properties4.cluster_id) {
424
+ const leaves = this.getLeaves(feature.properties.cluster_id, Infinity, 0) || [];
425
+ pointCount = leaves.length;
426
+ }
427
+
428
+ // if this cluster effectively contains only one original marker, return the original marker
429
+ if ((pointCount === 1 || pointCount === '1') && feature.properties) {
430
+ // try to get the original marker by marker_id from leaves or properties
431
+ let leaf = null;
432
+ if (feature.properties.cluster_id) {
433
+ const leaves = this.getLeaves(feature.properties.cluster_id, 1, 0);
434
+ leaf = leaves && leaves[0];
435
+ } else if (feature.properties.marker_id !== undefined) {
436
+ leaf = feature;
437
+ }
438
+ if (leaf && leaf.properties && typeof leaf.properties.marker_id === 'number') {
439
+ const origin = this.normalMarker(leaf);
440
+ if (origin) {
441
+ // ensure aggregated properties are available on the original marker
442
+ try {
443
+ if (feature && feature.properties && typeof origin.setExtData === 'function') {
444
+ origin.setExtData(feature.properties);
445
+ }
446
+ } catch (e) {
447
+ void e;
448
+ }
449
+ return origin;
450
+ }
451
+ }
452
+ // fallback: if no marker_id, continue to render cluster element
453
+ }
454
+
455
+ // for real clusters (count > 1) or fallback, create cluster marker element
456
+ let el;
457
+ if (typeof element === 'function') {
458
+ el = element(feature);
459
+ } else {
460
+ // element may be a DOM node already
461
+ el = element;
462
+ }
271
463
  const marker = new Marker({
272
- element: element(feature)
464
+ element: el
273
465
  }).setLnglat({
274
466
  lng: feature.geometry.coordinates[0],
275
467
  lat: feature.geometry.coordinates[1]
276
468
  });
469
+ // attach aggregated properties to the cluster marker so getExtData() returns useful info
470
+ if (feature && feature.properties) {
471
+ // @ts-ignore
472
+ marker.setExtData(feature.properties);
473
+ }
277
474
  return marker;
278
475
  }
279
476
  normalMarker(feature) {
package/es/marker.d.ts CHANGED
@@ -9,6 +9,7 @@ export default class Marker extends EventEmitter {
9
9
  private scene;
10
10
  private added;
11
11
  private preLngLat;
12
+ private visible;
12
13
  getMarkerLayerContainerSize(): IMarkerContainerAndBounds | void;
13
14
  constructor(option?: Partial<IMarkerOption>);
14
15
  getDefault(): {
@@ -21,6 +22,14 @@ export default class Marker extends EventEmitter {
21
22
  };
22
23
  addTo(scene: L7Container): this;
23
24
  remove(): this;
25
+ /**
26
+ * Hide the marker visually but keep it in the layer's data structures.
27
+ */
28
+ hide(): this;
29
+ /**
30
+ * Show the marker if it was hidden.
31
+ */
32
+ show(): this;
24
33
  setLnglat(lngLat: ILngLat | IPoint): this;
25
34
  getLnglat(): ILngLat;
26
35
  getElement(): HTMLElement;
@@ -35,7 +44,7 @@ export default class Marker extends EventEmitter {
35
44
  getDraggable(): boolean;
36
45
  getExtData(): any;
37
46
  setExtData(data: any): void;
38
- private update;
47
+ update(): void;
39
48
  private updatePositionWhenZoom;
40
49
  private onMapClick;
41
50
  private getCurrentContainerSize;
package/es/marker.js CHANGED
@@ -19,6 +19,7 @@ export default class Marker extends EventEmitter {
19
19
  lng: 0,
20
20
  lat: 0
21
21
  });
22
+ _defineProperty(this, "visible", true);
22
23
  _defineProperty(this, "onMarkerDragStart", e => {
23
24
  const mapContainer = this.mapsService.getContainer();
24
25
  if (!mapContainer) {
@@ -105,7 +106,8 @@ export default class Marker extends EventEmitter {
105
106
  } = this.markerOption;
106
107
  this.mapsService.getMarkerContainer().appendChild(element);
107
108
  this.registerMarkerEvent(element);
108
- this.mapsService.on('camerachange', this.update); // 注册高德1.x 的地图事件监听
109
+ // marker 不再在自身注册地图相机事件,以避免为每个 marker 注册大量底层 map 监听器。
110
+ // 由 MarkerLayer 在 addTo 时统一注册并在相机变化时调用每个 marker.update()。
109
111
  this.update();
110
112
  this.updateDraggable();
111
113
  this.added = true;
@@ -114,10 +116,7 @@ export default class Marker extends EventEmitter {
114
116
  }
115
117
  remove() {
116
118
  if (this.mapsService) {
117
- this.mapsService.off('click', this.onMapClick);
118
- this.mapsService.off('move', this.update);
119
- this.mapsService.off('moveend', this.update);
120
- this.mapsService.off('camerachange', this.update);
119
+ // 不再负责移除地图级别的 update 监听(由 MarkerLayer 管理),移除地图事件请统一通过 layer
121
120
  }
122
121
  this.unRegisterMarkerEvent();
123
122
  this.removeAllListeners();
@@ -132,6 +131,36 @@ export default class Marker extends EventEmitter {
132
131
  }
133
132
  return this;
134
133
  }
134
+
135
+ /**
136
+ * Hide the marker visually but keep it in the layer's data structures.
137
+ */
138
+ hide() {
139
+ const {
140
+ element
141
+ } = this.markerOption;
142
+ if (element) {
143
+ element.style.display = 'none';
144
+ }
145
+ this.visible = false;
146
+ return this;
147
+ }
148
+
149
+ /**
150
+ * Show the marker if it was hidden.
151
+ */
152
+ show() {
153
+ const {
154
+ element
155
+ } = this.markerOption;
156
+ if (element) {
157
+ element.style.display = 'block';
158
+ }
159
+ this.visible = true;
160
+ // re-position after showing
161
+ this.update();
162
+ return this;
163
+ }
135
164
  setLnglat(lngLat) {
136
165
  this.lngLat = lngLat;
137
166
  if (Array.isArray(lngLat)) {
@@ -262,6 +291,9 @@ export default class Marker extends EventEmitter {
262
291
  lng,
263
292
  lat
264
293
  } = this.lngLat;
294
+ if (!this.visible) {
295
+ return;
296
+ }
265
297
  if (element) {
266
298
  element.style.display = 'block';
267
299
  element.style.whiteSpace = 'nowrap';
@@ -300,7 +332,6 @@ export default class Marker extends EventEmitter {
300
332
  element.style.transition = 'left 0.25s cubic-bezier(0,0,0.25,1), top 0.25s cubic-bezier(0,0,0.25,1)';
301
333
  }
302
334
  }
303
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
304
335
  onMapClick(e) {
305
336
  const {
306
337
  element
@@ -341,6 +372,13 @@ export default class Marker extends EventEmitter {
341
372
  lat
342
373
  } = this.lngLat;
343
374
  const pos = this.mapsService.lngLatToContainer([lng, lat]);
375
+ if (!this.visible) {
376
+ // remain hidden until show() is called
377
+ if (element) {
378
+ element.style.display = 'none';
379
+ }
380
+ return;
381
+ }
344
382
  if (element) {
345
383
  element.style.display = 'block';
346
384
  element.style.whiteSpace = 'nowrap';
@@ -454,13 +492,9 @@ export default class Marker extends EventEmitter {
454
492
  }
455
493
  }
456
494
  }
457
-
458
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
459
495
  addDragHandler(e) {
460
496
  return null;
461
497
  }
462
-
463
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
464
498
  onUp(e) {
465
499
  throw new Error('Method not implemented.');
466
500
  }
@@ -17,7 +17,7 @@ export type LayerPopupConfigItem = {
17
17
  export interface ILayerPopupOption extends IPopupOption {
18
18
  config?: LayerPopupConfigItem[];
19
19
  items?: LayerPopupConfigItem[];
20
- trigger: 'hover' | 'click';
20
+ trigger: 'hover' | 'click' | 'touchend' | 'touchstart';
21
21
  }
22
22
  type LayerMapInfo = {
23
23
  onMouseMove?: (layer: ILayer, e: any) => void;
@@ -45,6 +45,12 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
45
45
  featureId: number;
46
46
  };
47
47
  protected get layerConfigItems(): LayerPopupConfigItem[];
48
+ /**
49
+ * 根据环境获取实际的触发事件
50
+ * 当 trigger 为 'click' 时,移动端使用 'touchend',PC 端使用 'click'
51
+ * @protected
52
+ */
53
+ protected getActualTriggerEvent(): "hover" | "click" | "touchstart" | "touchend";
48
54
  addTo(scene: L7Container): this;
49
55
  remove(): this;
50
56
  setOptions(option: Partial<ILayerPopupOption>): this;
@@ -60,7 +66,7 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
60
66
  */
61
67
  protected unbindLayerEvent(): void;
62
68
  protected onLayerMouseMove(layer: ILayer, e: any): void;
63
- protected onLayerMouseOut(layer: ILayer, e: any): void;
69
+ protected onLayerMouseOut(layer: ILayer): void;
64
70
  protected onLayerClick: (layer: ILayer, e: any) => void;
65
71
  protected onSceneClick: () => void;
66
72
  protected onSourceUpdate(): void;
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import { DOM, lodashUtil } from '@antv/l7-utils';
3
+ import { DOM, isPC, lodashUtil } from '@antv/l7-utils';
4
4
  import Popup from "./popup";
5
5
  const {
6
6
  get
@@ -72,6 +72,21 @@ export default class LayerPopup extends Popup {
72
72
  } = this.popupOption;
73
73
  return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
74
74
  }
75
+
76
+ /**
77
+ * 根据环境获取实际的触发事件
78
+ * 当 trigger 为 'click' 时,移动端使用 'touchend',PC 端使用 'click'
79
+ * @protected
80
+ */
81
+ getActualTriggerEvent() {
82
+ const {
83
+ trigger
84
+ } = this.popupOption;
85
+ if (trigger === 'click') {
86
+ return isPC() ? 'click' : 'touchend';
87
+ }
88
+ return trigger;
89
+ }
75
90
  addTo(scene) {
76
91
  super.addTo(scene);
77
92
  this.bindLayerEvent();
@@ -99,7 +114,7 @@ export default class LayerPopup extends Popup {
99
114
  return this;
100
115
  }
101
116
  getDefault(option) {
102
- const isHoverTrigger = option.trigger !== 'click';
117
+ const isHoverTrigger = option.trigger === 'hover';
103
118
  return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
104
119
  trigger: 'hover',
105
120
  followCursor: isHoverTrigger,
@@ -124,6 +139,7 @@ export default class LayerPopup extends Popup {
124
139
  trigger,
125
140
  closeOnClick
126
141
  } = this.popupOption;
142
+ const actualTrigger = this.getActualTriggerEvent();
127
143
  this.layerConfigItems.forEach(configItem => {
128
144
  var _layer$getSource;
129
145
  const layer = this.getLayerByConfig(configItem);
@@ -142,10 +158,10 @@ export default class LayerPopup extends Popup {
142
158
  var _this$mapsService;
143
159
  const onLayerClick = this.onLayerClick.bind(this, layer);
144
160
  layerInfo.onClick = onLayerClick;
145
- layer === null || layer === void 0 || layer.on('click', onLayerClick);
161
+ layer === null || layer === void 0 || layer.on(actualTrigger, onLayerClick);
146
162
  const mapContainer = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getMapContainer();
147
163
  if (mapContainer && closeOnClick) {
148
- mapContainer.addEventListener('click', this.onSceneClick);
164
+ mapContainer.addEventListener(actualTrigger, this.onSceneClick);
149
165
  }
150
166
  }
151
167
  const source = layer === null || layer === void 0 || (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
@@ -161,6 +177,7 @@ export default class LayerPopup extends Popup {
161
177
  * @protected
162
178
  */
163
179
  unbindLayerEvent() {
180
+ const actualTrigger = this.getActualTriggerEvent();
164
181
  this.layerConfigItems.forEach(configItem => {
165
182
  var _this$mapsService2;
166
183
  const layer = this.getLayerByConfig(configItem);
@@ -181,7 +198,7 @@ export default class LayerPopup extends Popup {
181
198
  layer.off('mouseout', onMouseOut);
182
199
  }
183
200
  if (onClick) {
184
- layer.off('click', onClick);
201
+ layer.off(actualTrigger, onClick);
185
202
  }
186
203
  if (onSourceUpdate) {
187
204
  var _layer$getSource2;
@@ -189,7 +206,7 @@ export default class LayerPopup extends Popup {
189
206
  }
190
207
  const mapContainer = (_this$mapsService2 = this.mapsService) === null || _this$mapsService2 === void 0 ? void 0 : _this$mapsService2.getMapContainer();
191
208
  if (mapContainer) {
192
- mapContainer.removeEventListener('click', this.onSceneClick);
209
+ mapContainer.removeEventListener(actualTrigger, this.onSceneClick);
193
210
  }
194
211
  });
195
212
  }
@@ -208,9 +225,7 @@ export default class LayerPopup extends Popup {
208
225
  this.show();
209
226
  }
210
227
  }
211
-
212
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
213
- onLayerMouseOut(layer, e) {
228
+ onLayerMouseOut(layer) {
214
229
  this.setDisplayFeatureInfo(undefined);
215
230
  if (this.isShow) {
216
231
  this.hide();
package/es/popup/popup.js CHANGED
@@ -436,7 +436,6 @@ export default class Popup extends EventEmitter {
436
436
  isOpen() {
437
437
  return !!this.mapsService;
438
438
  }
439
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
440
439
  getDefault(option) {
441
440
  // tslint:disable-next-line:no-object-literal-type-assertion
442
441
  return {
@@ -129,7 +129,11 @@ class LayerSwitch extends _selectControl.default {
129
129
  // 如果是单选模式,则只显示第一个图层
130
130
  handleSingleSelection() {
131
131
  this.layers.forEach((layer, index) => {
132
- index === 0 ? layer.show() : layer.hide();
132
+ if (index === 0) {
133
+ layer.show();
134
+ } else {
135
+ layer.hide();
136
+ }
133
137
  });
134
138
  }
135
139
  onAdd() {