@antv/l7-component 2.20.11 → 2.20.13

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.
@@ -17,6 +17,7 @@ export default class LayerSwitch extends SelectControl<ILayerSwitchOption> {
17
17
  getLayerVisible(): string[];
18
18
  getLayerOptions(): ControlOptionItem[];
19
19
  setOptions(option: Partial<ILayerSwitchOption>): void;
20
+ private handleSingleSelectionMode;
20
21
  onAdd(): HTMLElement;
21
22
  onRemove(): void;
22
23
  protected onLayerChange: () => void;
@@ -142,21 +142,30 @@ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
142
142
  var isLayerChange = this.checkUpdateOption(option, ['layers', 'multiple']);
143
143
  _get(_getPrototypeOf(LayerSwitch.prototype), "setOptions", this).call(this, option);
144
144
  if (isLayerChange) {
145
+ if (this.controlOption.multiple === false) {
146
+ this.handleSingleSelectionMode();
147
+ }
145
148
  this.selectValue = this.getLayerVisible();
146
149
  this.controlOption.options = this.getLayerOptions();
147
150
  this.popper.setContent(this.getPopperContent(this.controlOption.options));
148
151
  }
149
152
  }
153
+
154
+ // TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
155
+ // 如果是单选模式,则只显示第一个图层
156
+ }, {
157
+ key: "handleSingleSelectionMode",
158
+ value: function handleSingleSelectionMode() {
159
+ this.layers.forEach(function (layer, index) {
160
+ index === 0 ? layer.show() : layer.hide();
161
+ });
162
+ }
150
163
  }, {
151
164
  key: "onAdd",
152
165
  value: function onAdd() {
153
166
  var _this$controlOption$o;
154
- // TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
155
- // 如果是单选模式,则只显示第一个图层
156
167
  if (this.controlOption.multiple === false) {
157
- this.layers.forEach(function (layer, index) {
158
- index === 0 ? layer.show() : layer.hide();
159
- });
168
+ this.handleSingleSelectionMode();
160
169
  }
161
170
  if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
162
171
  this.controlOption.options = this.getLayerOptions();
@@ -88,6 +88,11 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
88
88
  * @protected
89
89
  */
90
90
  protected isSameFeature(layer: ILayer, featureId: number): boolean | undefined;
91
+ protected setDisplayFeatureInfo(displayFeatureInfo?: {
92
+ layer: ILayer;
93
+ featureId: number;
94
+ }): void;
95
+ protected onLayerHide: () => void;
91
96
  /**
92
97
  * 覆盖 Popup 中的默认的 closeOnClick 行为
93
98
  */
@@ -46,10 +46,10 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
46
46
  _this.setDOMContent(content);
47
47
  _this.setLnglat(e.lngLat);
48
48
  _this.setTitle(title);
49
- _this.displayFeatureInfo = {
49
+ _this.setDisplayFeatureInfo({
50
50
  layer: layer,
51
51
  featureId: e.featureId
52
- };
52
+ });
53
53
  _this.show();
54
54
  }
55
55
  });
@@ -62,6 +62,10 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
62
62
  }
63
63
  });
64
64
  });
65
+ _defineProperty(_assertThisInitialized(_this), "onLayerHide", function () {
66
+ _this.hide();
67
+ _this.setDisplayFeatureInfo(undefined);
68
+ });
65
69
  /**
66
70
  * 覆盖 Popup 中的默认的 closeOnClick 行为
67
71
  */
@@ -224,10 +228,10 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
224
228
  content = _this$getLayerInfoFra2.content;
225
229
  this.setDOMContent(content);
226
230
  this.setTitle(title);
227
- this.displayFeatureInfo = {
231
+ this.setDisplayFeatureInfo({
228
232
  layer: layer,
229
233
  featureId: e.featureId
230
- };
234
+ });
231
235
  this.show();
232
236
  }
233
237
  }
@@ -236,7 +240,7 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
236
240
  }, {
237
241
  key: "onLayerMouseOut",
238
242
  value: function onLayerMouseOut(layer, e) {
239
- this.displayFeatureInfo = undefined;
243
+ this.setDisplayFeatureInfo(undefined);
240
244
  if (this.isShow) {
241
245
  this.hide();
242
246
  }
@@ -245,7 +249,7 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
245
249
  key: "onSourceUpdate",
246
250
  value: function onSourceUpdate() {
247
251
  this.hide();
248
- this.displayFeatureInfo = undefined;
252
+ this.setDisplayFeatureInfo(undefined);
249
253
  }
250
254
 
251
255
  /**
@@ -345,6 +349,18 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
345
349
  var displayFeatureInfo = this.displayFeatureInfo;
346
350
  return displayFeatureInfo && layer === displayFeatureInfo.layer && featureId === displayFeatureInfo.featureId;
347
351
  }
352
+ }, {
353
+ key: "setDisplayFeatureInfo",
354
+ value: function setDisplayFeatureInfo(displayFeatureInfo) {
355
+ var oldDisplayFeatureInfo = this.displayFeatureInfo;
356
+ if (oldDisplayFeatureInfo) {
357
+ oldDisplayFeatureInfo.layer.off('hide', this.onLayerHide);
358
+ }
359
+ if (displayFeatureInfo) {
360
+ displayFeatureInfo.layer.on('hide', this.onLayerHide);
361
+ }
362
+ this.displayFeatureInfo = displayFeatureInfo;
363
+ }
348
364
  }]);
349
365
  return LayerPopup;
350
366
  }(Popup);
@@ -148,21 +148,30 @@ var LayerSwitch = exports.default = exports.LayerSwitch = /*#__PURE__*/function
148
148
  var isLayerChange = this.checkUpdateOption(option, ['layers', 'multiple']);
149
149
  (0, _get2.default)((0, _getPrototypeOf2.default)(LayerSwitch.prototype), "setOptions", this).call(this, option);
150
150
  if (isLayerChange) {
151
+ if (this.controlOption.multiple === false) {
152
+ this.handleSingleSelectionMode();
153
+ }
151
154
  this.selectValue = this.getLayerVisible();
152
155
  this.controlOption.options = this.getLayerOptions();
153
156
  this.popper.setContent(this.getPopperContent(this.controlOption.options));
154
157
  }
155
158
  }
159
+
160
+ // TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
161
+ // 如果是单选模式,则只显示第一个图层
162
+ }, {
163
+ key: "handleSingleSelectionMode",
164
+ value: function handleSingleSelectionMode() {
165
+ this.layers.forEach(function (layer, index) {
166
+ index === 0 ? layer.show() : layer.hide();
167
+ });
168
+ }
156
169
  }, {
157
170
  key: "onAdd",
158
171
  value: function onAdd() {
159
172
  var _this$controlOption$o;
160
- // TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
161
- // 如果是单选模式,则只显示第一个图层
162
173
  if (this.controlOption.multiple === false) {
163
- this.layers.forEach(function (layer, index) {
164
- index === 0 ? layer.show() : layer.hide();
165
- });
174
+ this.handleSingleSelectionMode();
166
175
  }
167
176
  if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
168
177
  this.controlOption.options = this.getLayerOptions();
@@ -52,10 +52,10 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
52
52
  _this.setDOMContent(content);
53
53
  _this.setLnglat(e.lngLat);
54
54
  _this.setTitle(title);
55
- _this.displayFeatureInfo = {
55
+ _this.setDisplayFeatureInfo({
56
56
  layer: layer,
57
57
  featureId: e.featureId
58
- };
58
+ });
59
59
  _this.show();
60
60
  }
61
61
  });
@@ -68,6 +68,10 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
68
68
  }
69
69
  });
70
70
  });
71
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onLayerHide", function () {
72
+ _this.hide();
73
+ _this.setDisplayFeatureInfo(undefined);
74
+ });
71
75
  /**
72
76
  * 覆盖 Popup 中的默认的 closeOnClick 行为
73
77
  */
@@ -230,10 +234,10 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
230
234
  content = _this$getLayerInfoFra2.content;
231
235
  this.setDOMContent(content);
232
236
  this.setTitle(title);
233
- this.displayFeatureInfo = {
237
+ this.setDisplayFeatureInfo({
234
238
  layer: layer,
235
239
  featureId: e.featureId
236
- };
240
+ });
237
241
  this.show();
238
242
  }
239
243
  }
@@ -242,7 +246,7 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
242
246
  }, {
243
247
  key: "onLayerMouseOut",
244
248
  value: function onLayerMouseOut(layer, e) {
245
- this.displayFeatureInfo = undefined;
249
+ this.setDisplayFeatureInfo(undefined);
246
250
  if (this.isShow) {
247
251
  this.hide();
248
252
  }
@@ -251,7 +255,7 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
251
255
  key: "onSourceUpdate",
252
256
  value: function onSourceUpdate() {
253
257
  this.hide();
254
- this.displayFeatureInfo = undefined;
258
+ this.setDisplayFeatureInfo(undefined);
255
259
  }
256
260
 
257
261
  /**
@@ -351,6 +355,18 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
351
355
  var displayFeatureInfo = this.displayFeatureInfo;
352
356
  return displayFeatureInfo && layer === displayFeatureInfo.layer && featureId === displayFeatureInfo.featureId;
353
357
  }
358
+ }, {
359
+ key: "setDisplayFeatureInfo",
360
+ value: function setDisplayFeatureInfo(displayFeatureInfo) {
361
+ var oldDisplayFeatureInfo = this.displayFeatureInfo;
362
+ if (oldDisplayFeatureInfo) {
363
+ oldDisplayFeatureInfo.layer.off('hide', this.onLayerHide);
364
+ }
365
+ if (displayFeatureInfo) {
366
+ displayFeatureInfo.layer.on('hide', this.onLayerHide);
367
+ }
368
+ this.displayFeatureInfo = displayFeatureInfo;
369
+ }
354
370
  }]);
355
371
  return LayerPopup;
356
372
  }(_popup.default);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.20.11",
3
+ "version": "2.20.13",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -26,8 +26,8 @@
26
26
  "author": "lzxue",
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
- "@antv/l7-core": "2.20.11",
30
- "@antv/l7-utils": "2.20.11",
29
+ "@antv/l7-core": "2.20.13",
30
+ "@antv/l7-utils": "2.20.13",
31
31
  "@babel/runtime": "^7.7.7",
32
32
  "eventemitter3": "^4.0.0",
33
33
  "inversify": "^5.0.1",
@@ -35,12 +35,12 @@
35
35
  "supercluster": "^7.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@antv/l7-layers": "2.20.11",
39
- "@antv/l7-test-utils": "2.20.11",
38
+ "@antv/l7-layers": "2.20.13",
39
+ "@antv/l7-test-utils": "2.20.13",
40
40
  "gcoord": "^0.3.2",
41
41
  "less": "^4.1.3"
42
42
  },
43
- "gitHead": "40b9c778934bbcef548f1060bddf6de988b75c00",
43
+ "gitHead": "9487cca3bdd14eb2fc81b310e4eae5d30a30496f",
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  }