@antv/l7-component 2.10.4 → 2.10.5

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.
@@ -1,8 +1,8 @@
1
- import { ELType } from '@antv/l7-utils/src/dom';
1
+ import { DOM } from '@antv/l7-utils';
2
2
  import Control, { IControlOption } from './control';
3
3
  export { ButtonControl };
4
4
  export interface IButtonControlOption extends IControlOption {
5
- btnIcon?: ELType | DocumentFragment;
5
+ btnIcon?: DOM.ELType | DocumentFragment;
6
6
  btnText?: string;
7
7
  title?: string;
8
8
  vertical?: boolean;
@@ -27,7 +27,7 @@ export default class ButtonControl<O extends IButtonControlOption = IButtonContr
27
27
  * 按钮中图标对应的 DOM
28
28
  * @protected
29
29
  */
30
- protected buttonIcon?: ELType | DocumentFragment;
30
+ protected buttonIcon?: DOM.ELType | DocumentFragment;
31
31
  /**
32
32
  * 设置当前按钮
33
33
  * @param newIsDisable
@@ -1,10 +1,10 @@
1
1
  import { PositionType } from '@antv/l7-core';
2
- import { ELType } from '@antv/l7-utils/src/dom';
2
+ import { DOM } from '@antv/l7-utils';
3
3
  import { Control, IControlOption } from './baseControl';
4
4
  export interface IZoomControlOption extends IControlOption {
5
- zoomInText: ELType | string;
5
+ zoomInText: DOM.ELType | string;
6
6
  zoomInTitle: string;
7
- zoomOutText: ELType | string;
7
+ zoomOutText: DOM.ELType | string;
8
8
  zoomOutTitle: string;
9
9
  }
10
10
  export { Zoom };
@@ -3,8 +3,8 @@ import { Container } from 'inversify';
3
3
  import Popup from './popup';
4
4
  export declare type LayerField = {
5
5
  field: string;
6
- formatField?: (field: string) => string;
7
- formatValue?: (value: any) => any;
6
+ formatField?: ((field: string) => string) | string;
7
+ formatValue?: ((value: any) => any) | string;
8
8
  getValue?: (feature: any) => any;
9
9
  };
10
10
  export declare type LayerPopupConfigItem = {
@@ -12,7 +12,8 @@ export declare type LayerPopupConfigItem = {
12
12
  fields: Array<LayerField | string>;
13
13
  };
14
14
  export interface ILayerPopupOption extends IPopupOption {
15
- config: LayerPopupConfigItem[];
15
+ config?: LayerPopupConfigItem[];
16
+ items?: LayerPopupConfigItem[];
16
17
  trigger: 'hover' | 'click';
17
18
  }
18
19
  declare type LayerMapInfo = {
@@ -36,6 +37,7 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
36
37
  layer: ILayer;
37
38
  featureId: number;
38
39
  };
40
+ protected get layerConfigItems(): LayerPopupConfigItem[];
39
41
  addTo(scene: Container): this;
40
42
  remove(): this;
41
43
  setOptions(option: Partial<ILayerPopupOption>): this;
@@ -63,10 +65,10 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
63
65
  protected getLayerInfoFrag(layer: ILayer, e: any): DocumentFragment;
64
66
  /**
65
67
  * 通过 Layer 配置访问到真实的 Layer 实例
66
- * @param config
68
+ * @param configItem
67
69
  * @protected
68
70
  */
69
- protected getLayerByConfig(config: LayerPopupConfigItem): ILayer | undefined;
71
+ protected getLayerByConfig(configItem: LayerPopupConfigItem): ILayer | undefined;
70
72
  /**
71
73
  * 判断当前展示的 Feature 是否和上一次查看的一致
72
74
  * @param layer
@@ -40,6 +40,16 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
40
40
  }
41
41
 
42
42
  _createClass(LayerPopup, [{
43
+ key: "layerConfigItems",
44
+ get: function get() {
45
+ var _ref;
46
+
47
+ var _this$popupOption = this.popupOption,
48
+ config = _this$popupOption.config,
49
+ items = _this$popupOption.items;
50
+ return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
51
+ }
52
+ }, {
43
53
  key: "addTo",
44
54
  value: function addTo(scene) {
45
55
  _get(_getPrototypeOf(LayerPopup.prototype), "addTo", this).call(this, scene);
@@ -94,10 +104,10 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
94
104
  value: function bindLayerEvent() {
95
105
  var _this2 = this;
96
106
 
97
- var _this$popupOption = this.popupOption,
98
- config = _this$popupOption.config,
99
- trigger = _this$popupOption.trigger;
100
- config.forEach(function (configItem) {
107
+ var trigger = this.popupOption.trigger;
108
+ this.layerConfigItems.forEach(function (configItem) {
109
+ var _layer$getSource;
110
+
101
111
  var layer = _this2.getLayerByConfig(configItem);
102
112
 
103
113
  if (!layer) {
@@ -122,7 +132,7 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
122
132
  layer === null || layer === void 0 ? void 0 : layer.on('click', onClick);
123
133
  }
124
134
 
125
- var source = layer.getSource();
135
+ var source = layer === null || layer === void 0 ? void 0 : (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
126
136
 
127
137
  var onSourceUpdate = _this2.onSourceUpdate.bind(_this2, layer);
128
138
 
@@ -142,8 +152,7 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
142
152
  value: function unbindLayerEvent() {
143
153
  var _this3 = this;
144
154
 
145
- var config = this.popupOption.config;
146
- config.forEach(function (configItem) {
155
+ this.layerConfigItems.forEach(function (configItem) {
147
156
  var layer = _this3.getLayerByConfig(configItem);
148
157
 
149
158
  var layerInfo = layer && _this3.layerConfigMap.get(layer);
@@ -170,9 +179,9 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
170
179
  }
171
180
 
172
181
  if (onSourceUpdate) {
173
- var _layer$getSource;
182
+ var _layer$getSource2;
174
183
 
175
- layer === null || layer === void 0 ? void 0 : (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.off('update', onSourceUpdate);
184
+ layer === null || layer === void 0 ? void 0 : (_layer$getSource2 = layer.getSource()) === null || _layer$getSource2 === void 0 ? void 0 : _layer$getSource2.off('update', onSourceUpdate);
176
185
  }
177
186
  });
178
187
  }
@@ -249,17 +258,22 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
249
258
 
250
259
  var fields = layerInfo.fields;
251
260
  fields === null || fields === void 0 ? void 0 : fields.forEach(function (fieldConfig) {
252
- var _ref = typeof fieldConfig === 'string' ? {
261
+ var _ref3, _ref4;
262
+
263
+ var _ref2 = typeof fieldConfig === 'string' ? // tslint:disable-next-line:no-object-literal-type-assertion
264
+ {
253
265
  field: fieldConfig
254
266
  } : fieldConfig,
255
- field = _ref.field,
256
- formatField = _ref.formatField,
257
- formatValue = _ref.formatValue,
258
- getValue = _ref.getValue;
267
+ field = _ref2.field,
268
+ formatField = _ref2.formatField,
269
+ formatValue = _ref2.formatValue,
270
+ getValue = _ref2.getValue;
259
271
 
260
272
  var row = DOM.create('div', 'l7-layer-popup__row');
261
273
  var value = getValue ? getValue(e.feature) : get(_feature, field);
262
- row.innerHTML = "".concat(formatField ? formatField(field) : field, ": ").concat(formatValue ? formatValue(value) : value);
274
+ var fieldText = (_ref3 = formatField instanceof Function ? formatField(field) : formatField) !== null && _ref3 !== void 0 ? _ref3 : field;
275
+ var valueText = (_ref4 = formatValue instanceof Function ? formatValue(value) : formatValue) !== null && _ref4 !== void 0 ? _ref4 : value;
276
+ row.innerHTML = "<span class=\"l7-layer-popup__key\">".concat(fieldText, "</span>: <span class=\"l7-layer-popup__value\">").concat(valueText, "</span>");
263
277
  frag.appendChild(row);
264
278
  });
265
279
  }
@@ -268,14 +282,14 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
268
282
  }
269
283
  /**
270
284
  * 通过 Layer 配置访问到真实的 Layer 实例
271
- * @param config
285
+ * @param configItem
272
286
  * @protected
273
287
  */
274
288
 
275
289
  }, {
276
290
  key: "getLayerByConfig",
277
- value: function getLayerByConfig(config) {
278
- var layer = config.layer;
291
+ value: function getLayerByConfig(configItem) {
292
+ var layer = configItem.layer;
279
293
 
280
294
  if (layer instanceof Object) {
281
295
  return layer;
@@ -55,6 +55,16 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
55
55
  }
56
56
 
57
57
  (0, _createClass2.default)(LayerPopup, [{
58
+ key: "layerConfigItems",
59
+ get: function get() {
60
+ var _ref;
61
+
62
+ var _this$popupOption = this.popupOption,
63
+ config = _this$popupOption.config,
64
+ items = _this$popupOption.items;
65
+ return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
66
+ }
67
+ }, {
58
68
  key: "addTo",
59
69
  value: function addTo(scene) {
60
70
  (0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "addTo", this).call(this, scene);
@@ -105,10 +115,10 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
105
115
  value: function bindLayerEvent() {
106
116
  var _this2 = this;
107
117
 
108
- var _this$popupOption = this.popupOption,
109
- config = _this$popupOption.config,
110
- trigger = _this$popupOption.trigger;
111
- config.forEach(function (configItem) {
118
+ var trigger = this.popupOption.trigger;
119
+ this.layerConfigItems.forEach(function (configItem) {
120
+ var _layer$getSource;
121
+
112
122
  var layer = _this2.getLayerByConfig(configItem);
113
123
 
114
124
  if (!layer) {
@@ -133,7 +143,7 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
133
143
  layer === null || layer === void 0 ? void 0 : layer.on('click', onClick);
134
144
  }
135
145
 
136
- var source = layer.getSource();
146
+ var source = layer === null || layer === void 0 ? void 0 : (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
137
147
 
138
148
  var onSourceUpdate = _this2.onSourceUpdate.bind(_this2, layer);
139
149
 
@@ -153,8 +163,7 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
153
163
  value: function unbindLayerEvent() {
154
164
  var _this3 = this;
155
165
 
156
- var config = this.popupOption.config;
157
- config.forEach(function (configItem) {
166
+ this.layerConfigItems.forEach(function (configItem) {
158
167
  var layer = _this3.getLayerByConfig(configItem);
159
168
 
160
169
  var layerInfo = layer && _this3.layerConfigMap.get(layer);
@@ -181,9 +190,9 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
181
190
  }
182
191
 
183
192
  if (onSourceUpdate) {
184
- var _layer$getSource;
193
+ var _layer$getSource2;
185
194
 
186
- layer === null || layer === void 0 ? void 0 : (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.off('update', onSourceUpdate);
195
+ layer === null || layer === void 0 ? void 0 : (_layer$getSource2 = layer.getSource()) === null || _layer$getSource2 === void 0 ? void 0 : _layer$getSource2.off('update', onSourceUpdate);
187
196
  }
188
197
  });
189
198
  }
@@ -260,18 +269,23 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
260
269
 
261
270
  var fields = layerInfo.fields;
262
271
  fields === null || fields === void 0 ? void 0 : fields.forEach(function (fieldConfig) {
263
- var _ref = typeof fieldConfig === 'string' ? {
272
+ var _ref3, _ref4;
273
+
274
+ var _ref2 = typeof fieldConfig === 'string' ? // tslint:disable-next-line:no-object-literal-type-assertion
275
+ {
264
276
  field: fieldConfig
265
277
  } : fieldConfig,
266
- field = _ref.field,
267
- formatField = _ref.formatField,
268
- formatValue = _ref.formatValue,
269
- getValue = _ref.getValue;
278
+ field = _ref2.field,
279
+ formatField = _ref2.formatField,
280
+ formatValue = _ref2.formatValue,
281
+ getValue = _ref2.getValue;
270
282
 
271
283
  var row = _l7Utils.DOM.create('div', 'l7-layer-popup__row');
272
284
 
273
285
  var value = getValue ? getValue(e.feature) : (0, _lodash.get)(_feature, field);
274
- row.innerHTML = "".concat(formatField ? formatField(field) : field, ": ").concat(formatValue ? formatValue(value) : value);
286
+ var fieldText = (_ref3 = formatField instanceof Function ? formatField(field) : formatField) !== null && _ref3 !== void 0 ? _ref3 : field;
287
+ var valueText = (_ref4 = formatValue instanceof Function ? formatValue(value) : formatValue) !== null && _ref4 !== void 0 ? _ref4 : value;
288
+ row.innerHTML = "<span class=\"l7-layer-popup__key\">".concat(fieldText, "</span>: <span class=\"l7-layer-popup__value\">").concat(valueText, "</span>");
275
289
  frag.appendChild(row);
276
290
  });
277
291
  }
@@ -280,14 +294,14 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
280
294
  }
281
295
  /**
282
296
  * 通过 Layer 配置访问到真实的 Layer 实例
283
- * @param config
297
+ * @param configItem
284
298
  * @protected
285
299
  */
286
300
 
287
301
  }, {
288
302
  key: "getLayerByConfig",
289
- value: function getLayerByConfig(config) {
290
- var layer = config.layer;
303
+ value: function getLayerByConfig(configItem) {
304
+ var layer = configItem.layer;
291
305
 
292
306
  if (layer instanceof Object) {
293
307
  return layer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.10.4",
3
+ "version": "2.10.5",
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.10.4",
30
- "@antv/l7-utils": "2.10.4",
29
+ "@antv/l7-core": "2.10.5",
30
+ "@antv/l7-utils": "2.10.5",
31
31
  "@babel/runtime": "^7.7.7",
32
32
  "eventemitter3": "^4.0.0",
33
33
  "inversify": "^5.0.1",
@@ -36,11 +36,11 @@
36
36
  "supercluster": "^7.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@antv/l7-test-utils": "2.10.4",
39
+ "@antv/l7-test-utils": "2.10.5",
40
40
  "gcoord": "^0.3.2",
41
41
  "less": "^4.1.3"
42
42
  },
43
- "gitHead": "4b25604adb5e066ef9779b3c52ae759a76c563c1",
43
+ "gitHead": "64bee613c3e1daedad46cb78de9a85b992392209",
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  }