@antv/l7-layers 2.11.7 → 2.12.1

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.
@@ -39,7 +39,6 @@ import { BlendTypes } from "../utils/blend";
39
39
  import { styleDataMapping } from "../utils/dataMappingStyle";
40
40
  import { calculateData } from "../utils/layerData";
41
41
  import { createMultiPassRenderer, normalizePasses } from "../utils/multiPassRender";
42
- import { updateShape } from "../utils/updateShape";
43
42
  import LayerPickService from "./LayerPickService";
44
43
  import TextureService from "./TextureService";
45
44
  /**
@@ -471,24 +470,18 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
471
470
  key: "filter",
472
471
  value: function filter(field, values, updateOptions) {
473
472
  this.updateStyleAttribute('filter', field, values, updateOptions);
473
+ this.dataState.dataSourceNeedUpdate = true;
474
474
  return this;
475
475
  }
476
476
  }, {
477
477
  key: "shape",
478
478
  value: function shape(field, values, updateOptions) {
479
- var _this$styleAttributeS, _this$styleAttributeS2, _this$styleAttributeS3;
480
-
481
- var lastShape = (_this$styleAttributeS = this.styleAttributeService) === null || _this$styleAttributeS === void 0 ? void 0 : (_this$styleAttributeS2 = _this$styleAttributeS.getLayerStyleAttribute('shape')) === null || _this$styleAttributeS2 === void 0 ? void 0 : (_this$styleAttributeS3 = _this$styleAttributeS2.scale) === null || _this$styleAttributeS3 === void 0 ? void 0 : _this$styleAttributeS3.field;
482
- var currentShape = field;
483
479
  this.shapeOption = {
484
480
  field: field,
485
481
  values: values
486
482
  };
487
- this.updateStyleAttribute('shape', field, values, updateOptions); // Tip: 根据 shape 判断是否需要更新 model
488
-
489
- if (!this.tileLayer) {
490
- updateShape(this, lastShape, currentShape);
491
- }
483
+ this.updateStyleAttribute('shape', field, values, updateOptions);
484
+ this.dataState.dataSourceNeedUpdate = true; // 通过数据更新驱动shape 更新
492
485
 
493
486
  return this;
494
487
  }
@@ -1294,8 +1287,8 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1294
1287
  value: function createAttributes(options) {
1295
1288
  var triangulation = options.triangulation; // @ts-ignore
1296
1289
 
1297
- var _this$styleAttributeS4 = this.styleAttributeService.createAttributes(this.encodedData, triangulation),
1298
- attributes = _this$styleAttributeS4.attributes;
1290
+ var _this$styleAttributeS = this.styleAttributeService.createAttributes(this.encodedData, triangulation),
1291
+ attributes = _this$styleAttributeS.attributes;
1299
1292
 
1300
1293
  return attributes;
1301
1294
  }
@@ -112,19 +112,12 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
112
112
 
113
113
  if (attributesToRemapping.length) {
114
114
  // 过滤数据
115
- if (filter !== null && filter !== void 0 && filter.needRemapping) {
116
- var encodeData = _this.mapping(layer, attributes, filterData, undefined);
115
+ var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
117
116
 
118
- layer.setEncodedData(encodeData);
119
- filter.needRemapping = false;
120
- } else {
121
- var _encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
117
+ layer.setEncodedData(encodeData);
118
+ } // 处理文本更新,更新文字形状
119
+ // layer.emit('remapping', null);
122
120
 
123
- layer.setEncodedData(_encodeData);
124
- } // 处理文本更新,更新文字形状
125
- // layer.emit('remapping', null);
126
-
127
- }
128
121
  });
129
122
  }
130
123
  }, {
@@ -166,6 +159,8 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
166
159
 
167
160
  var usedAttributes = attributes.filter(function (attribute) {
168
161
  return attribute.scale !== undefined;
162
+ }).filter(function (attribute) {
163
+ return attribute.name !== 'filter';
169
164
  });
170
165
  var mappedData = data.map(function (record, i) {
171
166
  var preRecord = predata ? predata[i] : {};
@@ -176,9 +171,8 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
176
171
  }, preRecord);
177
172
 
178
173
  usedAttributes.forEach(function (attribute) {
179
- var values = _this3.applyAttributeMapping(attribute, record);
174
+ var values = _this3.applyAttributeMapping(attribute, record); // TODO: 支持每个属性配置 postprocess
180
175
 
181
- attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
182
176
 
183
177
  if (attribute.name === 'color') {
184
178
  values = values.map(function (c) {
@@ -209,6 +203,9 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
209
203
  }
210
204
 
211
205
  return encodeRecord;
206
+ });
207
+ attributes.forEach(function (attribute) {
208
+ attribute.needRemapping = false;
212
209
  }); // 调整数据兼容 Amap2.0
213
210
 
214
211
  this.adjustData2Amap2Coordinates(mappedData, layer); // 调整数据兼容 SimpleCoordinates
@@ -14,8 +14,9 @@ import * as d3 from 'd3-scale';
14
14
  import { injectable } from 'inversify';
15
15
  import { isNil, isString, uniq } from 'lodash';
16
16
  import 'reflect-metadata';
17
+ import identity from "../utils/identityScale";
17
18
  var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
18
- var scaleMap = (_scaleMap = {}, _defineProperty(_scaleMap, ScaleTypes.LINEAR, d3.scaleLinear), _defineProperty(_scaleMap, ScaleTypes.POWER, d3.scalePow), _defineProperty(_scaleMap, ScaleTypes.LOG, d3.scaleLog), _defineProperty(_scaleMap, ScaleTypes.IDENTITY, d3.scaleIdentity), _defineProperty(_scaleMap, ScaleTypes.SEQUENTIAL, d3.scaleSequential), _defineProperty(_scaleMap, ScaleTypes.TIME, d3.scaleTime), _defineProperty(_scaleMap, ScaleTypes.QUANTILE, d3.scaleQuantile), _defineProperty(_scaleMap, ScaleTypes.QUANTIZE, d3.scaleQuantize), _defineProperty(_scaleMap, ScaleTypes.THRESHOLD, d3.scaleThreshold), _defineProperty(_scaleMap, ScaleTypes.CAT, d3.scaleOrdinal), _defineProperty(_scaleMap, ScaleTypes.DIVERGING, d3.scaleDiverging), _scaleMap);
19
+ var scaleMap = (_scaleMap = {}, _defineProperty(_scaleMap, ScaleTypes.LINEAR, d3.scaleLinear), _defineProperty(_scaleMap, ScaleTypes.POWER, d3.scalePow), _defineProperty(_scaleMap, ScaleTypes.LOG, d3.scaleLog), _defineProperty(_scaleMap, ScaleTypes.IDENTITY, identity), _defineProperty(_scaleMap, ScaleTypes.SEQUENTIAL, d3.scaleSequential), _defineProperty(_scaleMap, ScaleTypes.TIME, d3.scaleTime), _defineProperty(_scaleMap, ScaleTypes.QUANTILE, d3.scaleQuantile), _defineProperty(_scaleMap, ScaleTypes.QUANTIZE, d3.scaleQuantize), _defineProperty(_scaleMap, ScaleTypes.THRESHOLD, d3.scaleThreshold), _defineProperty(_scaleMap, ScaleTypes.CAT, d3.scaleOrdinal), _defineProperty(_scaleMap, ScaleTypes.DIVERGING, d3.scaleDiverging), _scaleMap);
19
20
  /**
20
21
  * 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用
21
22
  */
@@ -183,6 +184,10 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
183
184
 
184
185
  break;
185
186
 
187
+ case ScaleTypes.IDENTITY:
188
+ // 不做处理xe
189
+ break;
190
+
186
191
  case ScaleTypes.CAT:
187
192
  attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
188
193
  break;
@@ -313,10 +318,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
313
318
 
314
319
  if (scaleOption !== null && scaleOption !== void 0 && scaleOption.domain) {
315
320
  cfg.domain = scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.domain;
316
- } else if (type !== ScaleTypes.CAT && type !== ScaleTypes.QUANTILE && type !== ScaleTypes.DIVERGING) {
317
- // linear/
318
- cfg.domain = extent(values);
319
- } else if (type === ScaleTypes.CAT) {
321
+ } else if (type === ScaleTypes.CAT || type === ScaleTypes.IDENTITY) {
320
322
  cfg.domain = uniq(values);
321
323
  } else if (type === ScaleTypes.QUANTILE) {
322
324
  cfg.domain = values;
@@ -324,6 +326,9 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
324
326
  var minMax = extent(values);
325
327
  var neutral = (scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral) !== undefined ? scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral : (minMax[0] + minMax[1]) / 2;
326
328
  cfg.domain = [minMax[0], neutral, minMax[1]];
329
+ } else {
330
+ // linear/Power/log
331
+ cfg.domain = extent(values);
327
332
  }
328
333
 
329
334
  return _objectSpread(_objectSpread({}, cfg), scaleOption);
@@ -41,8 +41,8 @@ var RegisterStyleAttributePlugin = (_dec = injectable(), _dec(_class = /*#__PURE
41
41
  } // Tip: normal render layer
42
42
 
43
43
 
44
- this.registerPositionAttribute(styleAttributeService);
45
- this.registerFilterAttribute(styleAttributeService);
44
+ this.registerPositionAttribute(styleAttributeService); // this.registerFilterAttribute(styleAttributeService);//数据层数据过滤
45
+
46
46
  this.registerColorAttribute(styleAttributeService);
47
47
  this.registerVertexIdAttribute(styleAttributeService);
48
48
  }
@@ -585,7 +585,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
585
585
 
586
586
  var _ref9 = this.layer.getLayerConfig(),
587
587
  _ref9$padding = _ref9.padding,
588
- padding = _ref9$padding === void 0 ? [4, 4] : _ref9$padding,
588
+ padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
589
589
  _ref9$textAllowOverla = _ref9.textAllowOverlap,
590
590
  textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
591
591
 
@@ -76,6 +76,7 @@ export default abstract class Tile implements ITile {
76
76
  map?: import("@antv/l7-core").IMapWrapper | undefined;
77
77
  logoPosition?: import("@antv/l7-core").PositionName | undefined;
78
78
  logoVisible?: boolean | undefined;
79
+ isMini?: boolean | undefined;
79
80
  animate?: boolean | undefined;
80
81
  pickBufferScale?: number | undefined;
81
82
  stencil?: boolean | undefined;
@@ -0,0 +1,8 @@
1
+ export default function identity(d: any): {
2
+ (x: any): any;
3
+ invert: any;
4
+ domain: (v?: any) => any;
5
+ range(v?: any): any;
6
+ unknown(v: any): any;
7
+ copy(): any;
8
+ };
@@ -0,0 +1,34 @@
1
+ export default function identity(d) {
2
+ var unknown;
3
+ var domain = [];
4
+
5
+ function scale(x) {
6
+ return x == null ? unknown : x;
7
+ }
8
+
9
+ scale.invert = scale;
10
+
11
+ scale.domain = scale.range = function (v) {
12
+ if (v) {
13
+ domain = v;
14
+ return v;
15
+ }
16
+
17
+ return domain;
18
+ };
19
+
20
+ scale.unknown = function (v) {
21
+ if (v) {
22
+ unknown = v;
23
+ return v;
24
+ }
25
+
26
+ return unknown;
27
+ };
28
+
29
+ scale.copy = function () {
30
+ return identity(d).unknown(unknown);
31
+ };
32
+
33
+ return scale;
34
+ }
@@ -55,8 +55,6 @@ var _layerData = require("../utils/layerData");
55
55
 
56
56
  var _multiPassRender = require("../utils/multiPassRender");
57
57
 
58
- var _updateShape = require("../utils/updateShape");
59
-
60
58
  var _LayerPickService = _interopRequireDefault(require("./LayerPickService"));
61
59
 
62
60
  var _TextureService = _interopRequireDefault(require("./TextureService"));
@@ -474,24 +472,18 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
474
472
  key: "filter",
475
473
  value: function filter(field, values, updateOptions) {
476
474
  this.updateStyleAttribute('filter', field, values, updateOptions);
475
+ this.dataState.dataSourceNeedUpdate = true;
477
476
  return this;
478
477
  }
479
478
  }, {
480
479
  key: "shape",
481
480
  value: function shape(field, values, updateOptions) {
482
- var _this$styleAttributeS, _this$styleAttributeS2, _this$styleAttributeS3;
483
-
484
- var lastShape = (_this$styleAttributeS = this.styleAttributeService) === null || _this$styleAttributeS === void 0 ? void 0 : (_this$styleAttributeS2 = _this$styleAttributeS.getLayerStyleAttribute('shape')) === null || _this$styleAttributeS2 === void 0 ? void 0 : (_this$styleAttributeS3 = _this$styleAttributeS2.scale) === null || _this$styleAttributeS3 === void 0 ? void 0 : _this$styleAttributeS3.field;
485
- var currentShape = field;
486
481
  this.shapeOption = {
487
482
  field: field,
488
483
  values: values
489
484
  };
490
- this.updateStyleAttribute('shape', field, values, updateOptions); // Tip: 根据 shape 判断是否需要更新 model
491
-
492
- if (!this.tileLayer) {
493
- (0, _updateShape.updateShape)(this, lastShape, currentShape);
494
- }
485
+ this.updateStyleAttribute('shape', field, values, updateOptions);
486
+ this.dataState.dataSourceNeedUpdate = true; // 通过数据更新驱动shape 更新
495
487
 
496
488
  return this;
497
489
  }
@@ -1296,8 +1288,8 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1296
1288
  value: function createAttributes(options) {
1297
1289
  var triangulation = options.triangulation; // @ts-ignore
1298
1290
 
1299
- var _this$styleAttributeS4 = this.styleAttributeService.createAttributes(this.encodedData, triangulation),
1300
- attributes = _this$styleAttributeS4.attributes;
1291
+ var _this$styleAttributeS = this.styleAttributeService.createAttributes(this.encodedData, triangulation),
1292
+ attributes = _this$styleAttributeS.attributes;
1301
1293
 
1302
1294
  return attributes;
1303
1295
  }
@@ -133,19 +133,12 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
133
133
 
134
134
  if (attributesToRemapping.length) {
135
135
  // 过滤数据
136
- if (filter !== null && filter !== void 0 && filter.needRemapping) {
137
- var encodeData = _this.mapping(layer, attributes, filterData, undefined);
136
+ var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
138
137
 
139
- layer.setEncodedData(encodeData);
140
- filter.needRemapping = false;
141
- } else {
142
- var _encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
138
+ layer.setEncodedData(encodeData);
139
+ } // 处理文本更新,更新文字形状
140
+ // layer.emit('remapping', null);
143
141
 
144
- layer.setEncodedData(_encodeData);
145
- } // 处理文本更新,更新文字形状
146
- // layer.emit('remapping', null);
147
-
148
- }
149
142
  });
150
143
  }
151
144
  }, {
@@ -187,6 +180,8 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
187
180
 
188
181
  var usedAttributes = attributes.filter(function (attribute) {
189
182
  return attribute.scale !== undefined;
183
+ }).filter(function (attribute) {
184
+ return attribute.name !== 'filter';
190
185
  });
191
186
  var mappedData = data.map(function (record, i) {
192
187
  var preRecord = predata ? predata[i] : {};
@@ -195,9 +190,8 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
195
190
  coordinates: record.coordinates
196
191
  }, preRecord);
197
192
  usedAttributes.forEach(function (attribute) {
198
- var values = _this3.applyAttributeMapping(attribute, record);
193
+ var values = _this3.applyAttributeMapping(attribute, record); // TODO: 支持每个属性配置 postprocess
199
194
 
200
- attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
201
195
 
202
196
  if (attribute.name === 'color') {
203
197
  values = values.map(function (c) {
@@ -228,6 +222,9 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
228
222
  }
229
223
 
230
224
  return encodeRecord;
225
+ });
226
+ attributes.forEach(function (attribute) {
227
+ attribute.needRemapping = false;
231
228
  }); // 调整数据兼容 Amap2.0
232
229
 
233
230
  this.adjustData2Amap2Coordinates(mappedData, layer); // 调整数据兼容 SimpleCoordinates
@@ -35,6 +35,8 @@ var _lodash = require("lodash");
35
35
 
36
36
  require("reflect-metadata");
37
37
 
38
+ var _identityScale = _interopRequireDefault(require("../utils/identityScale"));
39
+
38
40
  var _scaleMap, _dec, _class;
39
41
 
40
42
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -42,7 +44,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
42
44
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
45
 
44
46
  var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
45
- var scaleMap = (_scaleMap = {}, (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LINEAR, d3.scaleLinear), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.POWER, d3.scalePow), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LOG, d3.scaleLog), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.IDENTITY, d3.scaleIdentity), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.SEQUENTIAL, d3.scaleSequential), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.TIME, d3.scaleTime), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTILE, d3.scaleQuantile), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTIZE, d3.scaleQuantize), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.THRESHOLD, d3.scaleThreshold), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.CAT, d3.scaleOrdinal), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.DIVERGING, d3.scaleDiverging), _scaleMap);
47
+ var scaleMap = (_scaleMap = {}, (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LINEAR, d3.scaleLinear), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.POWER, d3.scalePow), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LOG, d3.scaleLog), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.IDENTITY, _identityScale.default), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.SEQUENTIAL, d3.scaleSequential), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.TIME, d3.scaleTime), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTILE, d3.scaleQuantile), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTIZE, d3.scaleQuantize), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.THRESHOLD, d3.scaleThreshold), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.CAT, d3.scaleOrdinal), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.DIVERGING, d3.scaleDiverging), _scaleMap);
46
48
  /**
47
49
  * 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用
48
50
  */
@@ -209,6 +211,10 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
209
211
 
210
212
  break;
211
213
 
214
+ case _l7Core.ScaleTypes.IDENTITY:
215
+ // 不做处理xe
216
+ break;
217
+
212
218
  case _l7Core.ScaleTypes.CAT:
213
219
  attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
214
220
  break;
@@ -339,10 +345,7 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
339
345
 
340
346
  if (scaleOption !== null && scaleOption !== void 0 && scaleOption.domain) {
341
347
  cfg.domain = scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.domain;
342
- } else if (type !== _l7Core.ScaleTypes.CAT && type !== _l7Core.ScaleTypes.QUANTILE && type !== _l7Core.ScaleTypes.DIVERGING) {
343
- // linear/
344
- cfg.domain = (0, _d3Array.extent)(values);
345
- } else if (type === _l7Core.ScaleTypes.CAT) {
348
+ } else if (type === _l7Core.ScaleTypes.CAT || type === _l7Core.ScaleTypes.IDENTITY) {
346
349
  cfg.domain = (0, _lodash.uniq)(values);
347
350
  } else if (type === _l7Core.ScaleTypes.QUANTILE) {
348
351
  cfg.domain = values;
@@ -350,6 +353,9 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
350
353
  var minMax = (0, _d3Array.extent)(values);
351
354
  var neutral = (scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral) !== undefined ? scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral : (minMax[0] + minMax[1]) / 2;
352
355
  cfg.domain = [minMax[0], neutral, minMax[1]];
356
+ } else {
357
+ // linear/Power/log
358
+ cfg.domain = (0, _d3Array.extent)(values);
353
359
  }
354
360
 
355
361
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, cfg), scaleOption);
@@ -55,8 +55,8 @@ _dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
55
55
  } // Tip: normal render layer
56
56
 
57
57
 
58
- this.registerPositionAttribute(styleAttributeService);
59
- this.registerFilterAttribute(styleAttributeService);
58
+ this.registerPositionAttribute(styleAttributeService); // this.registerFilterAttribute(styleAttributeService);//数据层数据过滤
59
+
60
60
  this.registerColorAttribute(styleAttributeService);
61
61
  this.registerVertexIdAttribute(styleAttributeService);
62
62
  }
@@ -602,7 +602,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
602
602
 
603
603
  var _ref9 = this.layer.getLayerConfig(),
604
604
  _ref9$padding = _ref9.padding,
605
- padding = _ref9$padding === void 0 ? [4, 4] : _ref9$padding,
605
+ padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
606
606
  _ref9$textAllowOverla = _ref9.textAllowOverlap,
607
607
  textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
608
608
 
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = identity;
7
+
8
+ function identity(d) {
9
+ var unknown;
10
+ var domain = [];
11
+
12
+ function scale(x) {
13
+ return x == null ? unknown : x;
14
+ }
15
+
16
+ scale.invert = scale;
17
+
18
+ scale.domain = scale.range = function (v) {
19
+ if (v) {
20
+ domain = v;
21
+ return v;
22
+ }
23
+
24
+ return domain;
25
+ };
26
+
27
+ scale.unknown = function (v) {
28
+ if (v) {
29
+ unknown = v;
30
+ return v;
31
+ }
32
+
33
+ return unknown;
34
+ };
35
+
36
+ scale.copy = function () {
37
+ return identity(d).unknown(unknown);
38
+ };
39
+
40
+ return scale;
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.11.7",
3
+ "version": "2.12.1",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "@antv/async-hook": "^2.2.9",
30
- "@antv/l7-core": "2.11.7",
31
- "@antv/l7-maps": "2.11.7",
32
- "@antv/l7-source": "2.11.7",
33
- "@antv/l7-utils": "2.11.7",
30
+ "@antv/l7-core": "2.12.1",
31
+ "@antv/l7-maps": "2.12.1",
32
+ "@antv/l7-source": "2.12.1",
33
+ "@antv/l7-utils": "2.12.1",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -61,7 +61,7 @@
61
61
  "@types/gl-matrix": "^2.4.5",
62
62
  "@types/lodash": "^4.14.138"
63
63
  },
64
- "gitHead": "2cfdae91150313d75c87a21838b7512d0595052b",
64
+ "gitHead": "9e483bb35d0a9afeed94b3d68ce4b136e8356a32",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }
@@ -1,2 +0,0 @@
1
- import { ILayer, StyleAttributeField } from '@antv/l7-core';
2
- export declare function updateShape(layer: ILayer, lastShape: StyleAttributeField | undefined, currentShape: StyleAttributeField | undefined): void;
@@ -1,20 +0,0 @@
1
- // shapeUpdateList 存储一系列的 shape 类型
2
- // 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)
3
- var shapeUpdateList = [// PointLayer
4
- ['circle', 'cylinder'], ['square', 'cylinder'], ['triangle', 'cylinder'], ['pentagon', 'cylinder'], ['hexagon', 'cylinder'], ['octogon', 'cylinder'], ['hexagram', 'cylinder'], ['rhombus', 'cylinder'], ['vesica', 'cylinder']];
5
- export function updateShape(layer, lastShape, currentShape) {
6
- if (typeof lastShape === 'string' && typeof currentShape === 'string' && lastShape !== currentShape) {
7
- if (layer.type === 'PointLayer') {
8
- layer.dataState.dataSourceNeedUpdate = true;
9
- return;
10
- }
11
-
12
- shapeUpdateList.map(function (shapes) {
13
- if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
14
- // dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
15
- layer.dataState.dataSourceNeedUpdate = true;
16
- return;
17
- }
18
- });
19
- }
20
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.updateShape = updateShape;
7
- // shapeUpdateList 存储一系列的 shape 类型
8
- // 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)
9
- var shapeUpdateList = [// PointLayer
10
- ['circle', 'cylinder'], ['square', 'cylinder'], ['triangle', 'cylinder'], ['pentagon', 'cylinder'], ['hexagon', 'cylinder'], ['octogon', 'cylinder'], ['hexagram', 'cylinder'], ['rhombus', 'cylinder'], ['vesica', 'cylinder']];
11
-
12
- function updateShape(layer, lastShape, currentShape) {
13
- if (typeof lastShape === 'string' && typeof currentShape === 'string' && lastShape !== currentShape) {
14
- if (layer.type === 'PointLayer') {
15
- layer.dataState.dataSourceNeedUpdate = true;
16
- return;
17
- }
18
-
19
- shapeUpdateList.map(function (shapes) {
20
- if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
21
- // dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
22
- layer.dataState.dataSourceNeedUpdate = true;
23
- return;
24
- }
25
- });
26
- }
27
- }