@antv/l7-layers 2.20.16 → 2.20.17

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.
@@ -21,10 +21,13 @@ var BaseLayerPickService = /*#__PURE__*/function () {
21
21
  if (layer.tileLayer) {
22
22
  return layer.tileLayer.pickRender(target);
23
23
  }
24
+ // 渲染瓦片图层的拾取
25
+ layer.hooks.beforePickingEncode.call();
24
26
  layerService.renderTileLayerMask(layer);
25
27
  layer.renderModels({
26
28
  ispick: true
27
29
  });
30
+ layer.hooks.afterPickingEncode.call();
28
31
  }
29
32
  }, {
30
33
  key: "pick",
@@ -1,4 +1,4 @@
1
- import type { IAttributeAndElements, IRenderOptions } from '@antv/l7-core';
1
+ import type { IAttributeAndElements, ILegend, IRenderOptions } from '@antv/l7-core';
2
2
  import BaseLayer from '../core/BaseLayer';
3
3
  import type { IHeatMapLayerStyleOptions } from '../core/interface';
4
4
  import type { HeatMapModelType } from './models';
@@ -9,4 +9,5 @@ export default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {
9
9
  renderModels(options?: Partial<IRenderOptions>): this;
10
10
  updateModelData(data: IAttributeAndElements): void;
11
11
  getModelType(): HeatMapModelType;
12
+ getLegend(name: string): ILegend;
12
13
  }
@@ -2,6 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
+ import _get from "@babel/runtime/helpers/esm/get";
5
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
6
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
@@ -11,6 +12,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
13
  import BaseLayer from "../core/BaseLayer";
13
14
  import HeatMapModels from "./models";
15
+ import { rampColor2legend } from "../utils/rampcolor_legend";
14
16
  var HeatMapLayer = /*#__PURE__*/function (_BaseLayer) {
15
17
  _inherits(HeatMapLayer, _BaseLayer);
16
18
  var _super = _createSuper(HeatMapLayer);
@@ -114,6 +116,21 @@ var HeatMapLayer = /*#__PURE__*/function (_BaseLayer) {
114
116
  }
115
117
  return 'heatmap';
116
118
  }
119
+ }, {
120
+ key: "getLegend",
121
+ value: function getLegend(name) {
122
+ if (this.getModelType() === 'heatmap') {
123
+ if (name !== 'color') return {
124
+ type: undefined,
125
+ field: undefined,
126
+ items: []
127
+ };
128
+ var rampColors = this.getLayerConfig().rampColors;
129
+ return rampColor2legend(rampColors, name);
130
+ } else {
131
+ return _get(_getPrototypeOf(HeatMapLayer.prototype), "getLegend", this).call(this, name);
132
+ }
133
+ }
117
134
  }]);
118
135
  return HeatMapLayer;
119
136
  }(BaseLayer);
@@ -1,3 +1,4 @@
1
+ import type { ILegend } from '@antv/l7-core';
1
2
  import BaseLayer from '../core/BaseLayer';
2
3
  import type { IRasterLayerStyleOptions } from '../core/interface';
3
4
  import type { RasterModelType } from './models/index';
@@ -6,4 +7,5 @@ export default class RaterLayer extends BaseLayer<IRasterLayerStyleOptions> {
6
7
  buildModels(): Promise<void>;
7
8
  protected getDefaultConfig(): {} | {} | {} | {};
8
9
  getModelType(): RasterModelType;
10
+ getLegend(name: string): ILegend;
9
11
  }
@@ -11,6 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
12
  import BaseLayer from "../core/BaseLayer";
13
13
  import RasterModels from "./models/index";
14
+ import { rampColor2legend } from "../utils/rampcolor_legend";
14
15
  var RaterLayer = /*#__PURE__*/function (_BaseLayer) {
15
16
  _inherits(RaterLayer, _BaseLayer);
16
17
  var _super = _createSuper(RaterLayer);
@@ -77,6 +78,17 @@ var RaterLayer = /*#__PURE__*/function (_BaseLayer) {
77
78
  return 'raster';
78
79
  }
79
80
  }
81
+ }, {
82
+ key: "getLegend",
83
+ value: function getLegend(name) {
84
+ if (name !== 'color') return {
85
+ type: undefined,
86
+ field: undefined,
87
+ items: []
88
+ };
89
+ var rampColors = this.getLayerConfig().rampColors;
90
+ return rampColor2legend(rampColors, name);
91
+ }
80
92
  }]);
81
93
  return RaterLayer;
82
94
  }(BaseLayer);
@@ -0,0 +1,6 @@
1
+ import type { ILegend, ScaleTypeName } from '@antv/l7-core';
2
+ export declare function rampColor2legend(rampColors: {
3
+ type: ScaleTypeName;
4
+ colors: string[];
5
+ positions: number[];
6
+ }, name: string): ILegend;
@@ -0,0 +1,11 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ export function rampColor2legend(rampColors, name) {
3
+ return {
4
+ type: rampColors.type,
5
+ field: 'value',
6
+ items: rampColors.positions.map(function (value, index) {
7
+ var _ref;
8
+ return _ref = {}, _defineProperty(_ref, name, index >= rampColors.colors.length ? null : rampColors.colors[index]), _defineProperty(_ref, "value", value), _ref;
9
+ })
10
+ };
11
+ }
@@ -28,10 +28,13 @@ var BaseLayerPickService = exports.default = /*#__PURE__*/function () {
28
28
  if (layer.tileLayer) {
29
29
  return layer.tileLayer.pickRender(target);
30
30
  }
31
+ // 渲染瓦片图层的拾取
32
+ layer.hooks.beforePickingEncode.call();
31
33
  layerService.renderTileLayerMask(layer);
32
34
  layer.renderModels({
33
35
  ispick: true
34
36
  });
37
+ layer.hooks.afterPickingEncode.call();
35
38
  }
36
39
  }, {
37
40
  key: "pick",
@@ -10,12 +10,14 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
15
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
16
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
18
  var _BaseLayer2 = _interopRequireDefault(require("../core/BaseLayer"));
18
19
  var _models = _interopRequireDefault(require("./models"));
20
+ var _rampcolor_legend = require("../utils/rampcolor_legend");
19
21
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
20
22
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
23
  var HeatMapLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
@@ -121,6 +123,21 @@ var HeatMapLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
121
123
  }
122
124
  return 'heatmap';
123
125
  }
126
+ }, {
127
+ key: "getLegend",
128
+ value: function getLegend(name) {
129
+ if (this.getModelType() === 'heatmap') {
130
+ if (name !== 'color') return {
131
+ type: undefined,
132
+ field: undefined,
133
+ items: []
134
+ };
135
+ var rampColors = this.getLayerConfig().rampColors;
136
+ return (0, _rampcolor_legend.rampColor2legend)(rampColors, name);
137
+ } else {
138
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(HeatMapLayer.prototype), "getLegend", this).call(this, name);
139
+ }
140
+ }
124
141
  }]);
125
142
  return HeatMapLayer;
126
143
  }(_BaseLayer2.default);
@@ -16,6 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
17
  var _BaseLayer2 = _interopRequireDefault(require("../core/BaseLayer"));
18
18
  var _index = _interopRequireDefault(require("./models/index"));
19
+ var _rampcolor_legend = require("../utils/rampcolor_legend");
19
20
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
20
21
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
22
  var RaterLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
@@ -84,6 +85,17 @@ var RaterLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
84
85
  return 'raster';
85
86
  }
86
87
  }
88
+ }, {
89
+ key: "getLegend",
90
+ value: function getLegend(name) {
91
+ if (name !== 'color') return {
92
+ type: undefined,
93
+ field: undefined,
94
+ items: []
95
+ };
96
+ var rampColors = this.getLayerConfig().rampColors;
97
+ return (0, _rampcolor_legend.rampColor2legend)(rampColors, name);
98
+ }
87
99
  }]);
88
100
  return RaterLayer;
89
101
  }(_BaseLayer2.default);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.rampColor2legend = rampColor2legend;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ function rampColor2legend(rampColors, name) {
10
+ return {
11
+ type: rampColors.type,
12
+ field: 'value',
13
+ items: rampColors.positions.map(function (value, index) {
14
+ var _ref;
15
+ return _ref = {}, (0, _defineProperty2.default)(_ref, name, index >= rampColors.colors.length ? null : rampColors.colors[index]), (0, _defineProperty2.default)(_ref, "value", value), _ref;
16
+ })
17
+ };
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.20.16",
3
+ "version": "2.20.17",
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.20.16",
31
- "@antv/l7-maps": "2.20.16",
32
- "@antv/l7-source": "2.20.16",
33
- "@antv/l7-utils": "2.20.16",
30
+ "@antv/l7-core": "2.20.17",
31
+ "@antv/l7-maps": "2.20.17",
32
+ "@antv/l7-source": "2.20.17",
33
+ "@antv/l7-utils": "2.20.17",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -52,7 +52,7 @@
52
52
  "reflect-metadata": "^0.1.13"
53
53
  },
54
54
  "devDependencies": {
55
- "@antv/l7-test-utils": "2.20.16",
55
+ "@antv/l7-test-utils": "2.20.17",
56
56
  "@types/d3-array": "^2.0.0",
57
57
  "@types/d3-color": "^1.2.2",
58
58
  "@types/d3-interpolate": "1.1.6",
@@ -61,7 +61,7 @@
61
61
  "@types/gl-matrix": "^2.4.5",
62
62
  "@types/lodash": "^4.14.138"
63
63
  },
64
- "gitHead": "63b45d16a6d3cab498f5d6b298d51a6d30bb3f3b",
64
+ "gitHead": "e37d5cc24eec17a0949b827d76d1ac7c97a8fef3",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }