@antv/l7-layers 2.13.1 → 2.13.3

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.
@@ -590,12 +590,19 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
590
590
  }, {
591
591
  key: "scale",
592
592
  value: function scale(field, cfg) {
593
+ var preOption = _objectSpread({}, this.scaleOptions);
594
+
593
595
  if (isObject(field)) {
594
596
  this.scaleOptions = _objectSpread(_objectSpread({}, this.scaleOptions), field);
595
597
  } else {
596
598
  this.scaleOptions[field] = cfg;
597
599
  }
598
600
 
601
+ if (this.styleAttributeService && !isEqual(preOption, this.scaleOptions)) {
602
+ var scaleOptions = isObject(field) ? field : _defineProperty({}, field, cfg);
603
+ this.styleAttributeService.updateScaleAttribute(scaleOptions);
604
+ }
605
+
599
606
  return this;
600
607
  }
601
608
  /**
@@ -1062,8 +1069,8 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1062
1069
  } // this.layerSource.inited 为 true update 事件不会再触发
1063
1070
 
1064
1071
 
1065
- this.layerSource.on('update', function (_ref3) {
1066
- var type = _ref3.type;
1072
+ this.layerSource.on('update', function (_ref4) {
1073
+ var type = _ref4.type;
1067
1074
 
1068
1075
  if (_this8.coordCenter === undefined) {
1069
1076
  var _this8$mapService;
@@ -1193,9 +1200,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1193
1200
  }
1194
1201
  }, {
1195
1202
  key: "pick",
1196
- value: function pick(_ref7) {
1197
- var x = _ref7.x,
1198
- y = _ref7.y;
1203
+ value: function pick(_ref8) {
1204
+ var x = _ref8.x,
1205
+ y = _ref8.y;
1199
1206
  this.interactionService.triggerHover({
1200
1207
  x: x,
1201
1208
  y: y
@@ -1228,9 +1235,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1228
1235
  return _context3.abrupt("return", new Promise(function (resolve, reject) {
1229
1236
  // filter supported worker & worker enabled layer
1230
1237
  if (workerOptions && workerOptions.modelType in WorkerSourceMap && workerEnabled) {
1231
- _this10.styleAttributeService.createAttributesAndIndicesAscy(_this10.encodedData, segmentNumber, workerOptions).then(function (_ref8) {
1232
- var attributes = _ref8.attributes,
1233
- elements = _ref8.elements;
1238
+ _this10.styleAttributeService.createAttributesAndIndicesAscy(_this10.encodedData, segmentNumber, workerOptions).then(function (_ref9) {
1239
+ var attributes = _ref9.attributes,
1240
+ elements = _ref9.elements;
1234
1241
  var m = createModel(_objectSpread({
1235
1242
  attributes: attributes,
1236
1243
  uniforms: uniforms,
@@ -21,6 +21,6 @@ export declare class TilePickService implements ITilePickService {
21
21
  private color2PickId;
22
22
  private pickId2Color;
23
23
  /** 从瓦片中根据数据 */
24
- getFeatureById(pickedFeatureIdx: number): never[] | null;
24
+ getFeatureById(pickedFeatureIdx: number): any[];
25
25
  pickRasterLayer(layer: ILayer, target: IInteractionTarget, parent?: ILayer): boolean;
26
26
  }
@@ -148,18 +148,13 @@ export var TilePickService = /*#__PURE__*/function () {
148
148
  }); // 提取当前可见瓦片中匹配 ID 的 feature 列表
149
149
 
150
150
  var features = [];
151
- tiles.map(function (tile) {
151
+ tiles.forEach(function (tile) {
152
152
  features.push.apply(features, _toConsumableArray(tile.getFeatureById(pickedFeatureIdx)));
153
- });
154
-
155
- if (features.length <= 0) {
156
- return null;
157
- } // 将 feature 列表合并后返回
153
+ }); // 将 feature 列表合并后返回
158
154
  // 统一返回成 polygon 的格式 点、线、面可以通用
159
155
  // const data = this.tileSourceService.getCombineFeature(features);
160
156
 
161
-
162
- return [];
157
+ return features;
163
158
  } // Tip: for interface define
164
159
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
160
 
@@ -163,7 +163,8 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
163
163
  minZoom: this.z - 1
164
164
  });
165
165
  }
166
- }
166
+ } // 获取瓦片数据
167
+
167
168
  }, {
168
169
  key: "getFeatures",
169
170
  value: function getFeatures(sourceLayer) {
@@ -185,9 +186,10 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
185
186
  return [];
186
187
  }
187
188
 
188
- return layer.getSource().data.dataArray.filter(function (d) {
189
+ var res = layer.getSource().data.dataArray.filter(function (d) {
189
190
  return d._id === id;
190
191
  });
192
+ return res;
191
193
  }
192
194
  }]);
193
195
 
@@ -591,12 +591,19 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
591
591
  }, {
592
592
  key: "scale",
593
593
  value: function scale(field, cfg) {
594
+ var preOption = (0, _objectSpread2.default)({}, this.scaleOptions);
595
+
594
596
  if ((0, _lodash.isObject)(field)) {
595
597
  this.scaleOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.scaleOptions), field);
596
598
  } else {
597
599
  this.scaleOptions[field] = cfg;
598
600
  }
599
601
 
602
+ if (this.styleAttributeService && !(0, _lodash.isEqual)(preOption, this.scaleOptions)) {
603
+ var scaleOptions = (0, _lodash.isObject)(field) ? field : (0, _defineProperty2.default)({}, field, cfg);
604
+ this.styleAttributeService.updateScaleAttribute(scaleOptions);
605
+ }
606
+
600
607
  return this;
601
608
  }
602
609
  /**
@@ -1063,8 +1070,8 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1063
1070
  } // this.layerSource.inited 为 true update 事件不会再触发
1064
1071
 
1065
1072
 
1066
- this.layerSource.on('update', function (_ref3) {
1067
- var type = _ref3.type;
1073
+ this.layerSource.on('update', function (_ref4) {
1074
+ var type = _ref4.type;
1068
1075
 
1069
1076
  if (_this8.coordCenter === undefined) {
1070
1077
  var _this8$mapService;
@@ -1194,9 +1201,9 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1194
1201
  }
1195
1202
  }, {
1196
1203
  key: "pick",
1197
- value: function pick(_ref7) {
1198
- var x = _ref7.x,
1199
- y = _ref7.y;
1204
+ value: function pick(_ref8) {
1205
+ var x = _ref8.x,
1206
+ y = _ref8.y;
1200
1207
  this.interactionService.triggerHover({
1201
1208
  x: x,
1202
1209
  y: y
@@ -1229,9 +1236,9 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1229
1236
  return _context3.abrupt("return", new Promise(function (resolve, reject) {
1230
1237
  // filter supported worker & worker enabled layer
1231
1238
  if (workerOptions && workerOptions.modelType in _l7Utils.WorkerSourceMap && workerEnabled) {
1232
- _this10.styleAttributeService.createAttributesAndIndicesAscy(_this10.encodedData, segmentNumber, workerOptions).then(function (_ref8) {
1233
- var attributes = _ref8.attributes,
1234
- elements = _ref8.elements;
1239
+ _this10.styleAttributeService.createAttributesAndIndicesAscy(_this10.encodedData, segmentNumber, workerOptions).then(function (_ref9) {
1240
+ var attributes = _ref9.attributes,
1241
+ elements = _ref9.elements;
1235
1242
  var m = createModel((0, _objectSpread2.default)({
1236
1243
  attributes: attributes,
1237
1244
  uniforms: uniforms,
@@ -163,18 +163,13 @@ var TilePickService = /*#__PURE__*/function () {
163
163
  }); // 提取当前可见瓦片中匹配 ID 的 feature 列表
164
164
 
165
165
  var features = [];
166
- tiles.map(function (tile) {
166
+ tiles.forEach(function (tile) {
167
167
  features.push.apply(features, (0, _toConsumableArray2.default)(tile.getFeatureById(pickedFeatureIdx)));
168
- });
169
-
170
- if (features.length <= 0) {
171
- return null;
172
- } // 将 feature 列表合并后返回
168
+ }); // 将 feature 列表合并后返回
173
169
  // 统一返回成 polygon 的格式 点、线、面可以通用
174
170
  // const data = this.tileSourceService.getCombineFeature(features);
175
171
 
176
-
177
- return [];
172
+ return features;
178
173
  } // Tip: for interface define
179
174
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
180
175
 
@@ -180,7 +180,8 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
180
180
  minZoom: this.z - 1
181
181
  });
182
182
  }
183
- }
183
+ } // 获取瓦片数据
184
+
184
185
  }, {
185
186
  key: "getFeatures",
186
187
  value: function getFeatures(sourceLayer) {
@@ -202,9 +203,10 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
202
203
  return [];
203
204
  }
204
205
 
205
- return layer.getSource().data.dataArray.filter(function (d) {
206
+ var res = layer.getSource().data.dataArray.filter(function (d) {
206
207
  return d._id === id;
207
208
  });
209
+ return res;
208
210
  }
209
211
  }]);
210
212
  return VectorTile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.13.1",
3
+ "version": "2.13.3",
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.13.1",
31
- "@antv/l7-maps": "2.13.1",
32
- "@antv/l7-source": "2.13.1",
33
- "@antv/l7-utils": "2.13.1",
30
+ "@antv/l7-core": "2.13.3",
31
+ "@antv/l7-maps": "2.13.3",
32
+ "@antv/l7-source": "2.13.3",
33
+ "@antv/l7-utils": "2.13.3",
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": "6a7cbf5974ee1b3f38f926b3eaac97a144013ef2",
64
+ "gitHead": "c737d472363367279bc2fba8c14646a3d4af7bb7",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }