@antv/l7-layers 2.20.19 → 2.21.0
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.
- package/es/canvas/index.d.ts +13 -8
- package/es/canvas/index.js +63 -36
- package/es/canvas/models/canvas.d.ts +19 -14
- package/es/canvas/models/canvas.js +125 -139
- package/es/canvas/models/constants.d.ts +2 -0
- package/es/canvas/models/constants.js +6 -0
- package/es/canvas/models/index.d.ts +2 -5
- package/es/canvas/models/index.js +2 -5
- package/es/core/BaseLayer.d.ts +17 -19
- package/es/core/BaseLayer.js +88 -62
- package/es/core/BaseModel.js +15 -29
- package/es/core/LayerPickService.js +4 -5
- package/es/core/TextureService.js +1 -2
- package/es/core/interface.d.ts +31 -4
- package/es/core/shape/arrow.js +2 -6
- package/es/heatmap/models/heatmap.d.ts +0 -1
- package/es/heatmap/models/heatmap.js +2 -5
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -89
- package/es/line/models/arc.js +5 -5
- package/es/line/models/arc_3d.js +4 -3
- package/es/line/models/great_circle.js +4 -4
- package/es/line/models/line.js +5 -8
- package/es/line/models/simple_line.js +1 -2
- package/es/line/models/wall.js +4 -3
- package/es/plugins/DataMappingPlugin.d.ts +4 -7
- package/es/plugins/DataMappingPlugin.js +8 -23
- package/es/plugins/DataSourcePlugin.d.ts +0 -1
- package/es/plugins/DataSourcePlugin.js +4 -7
- package/es/plugins/FeatureScalePlugin.d.ts +2 -5
- package/es/plugins/FeatureScalePlugin.js +4 -6
- package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -1
- package/es/plugins/LayerAnimateStylePlugin.js +2 -5
- package/es/plugins/LayerMaskPlugin.d.ts +0 -1
- package/es/plugins/LayerMaskPlugin.js +2 -8
- package/es/plugins/LayerModelPlugin.d.ts +0 -1
- package/es/plugins/LayerModelPlugin.js +13 -18
- package/es/plugins/LayerStylePlugin.d.ts +0 -1
- package/es/plugins/LayerStylePlugin.js +2 -5
- package/es/plugins/LightingPlugin.d.ts +0 -1
- package/es/plugins/LightingPlugin.js +2 -5
- package/es/plugins/MultiPassRendererPlugin.d.ts +0 -1
- package/es/plugins/MultiPassRendererPlugin.js +2 -5
- package/es/plugins/PixelPickingPlugin.d.ts +2 -6
- package/es/plugins/PixelPickingPlugin.js +4 -9
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +2 -5
- package/es/plugins/RegisterStyleAttributePlugin.js +2 -5
- package/es/plugins/ShaderUniformPlugin.d.ts +7 -8
- package/es/plugins/ShaderUniformPlugin.js +16 -42
- package/es/plugins/UpdateModelPlugin.d.ts +0 -1
- package/es/plugins/UpdateModelPlugin.js +2 -5
- package/es/plugins/UpdateStyleAttributePlugin.d.ts +2 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +2 -6
- package/es/plugins/index.d.ts +15 -0
- package/es/plugins/index.js +18 -0
- package/es/point/models/fill.d.ts +1 -1
- package/es/point/models/fill.js +6 -9
- package/es/point/models/fillImage.js +4 -3
- package/es/point/models/image.js +4 -3
- package/es/polygon/models/extrude.js +0 -1
- package/es/polygon/models/ocean.js +1 -2
- package/es/polygon/models/water.js +0 -2
- package/es/tile/core/BaseLayer.js +4 -5
- package/es/tile/interaction/getRasterData.js +4 -16
- package/es/tile/service/TileLayerService.d.ts +0 -1
- package/es/tile/service/TileLayerService.js +0 -1
- package/es/tile/service/TilePickService.d.ts +1 -1
- package/es/tile/service/TilePickService.js +2 -3
- package/es/tile/tile/Tile.js +8 -6
- package/es/tile/utils/utils.d.ts +0 -4
- package/es/tile/utils/utils.js +0 -11
- package/lib/canvas/index.js +63 -37
- package/lib/canvas/models/canvas.js +125 -138
- package/lib/canvas/models/constants.js +12 -0
- package/lib/canvas/models/index.js +22 -7
- package/lib/core/BaseLayer.js +88 -62
- package/lib/core/BaseModel.js +14 -28
- package/lib/core/LayerPickService.js +4 -5
- package/lib/core/TextureService.js +1 -2
- package/lib/core/shape/arrow.js +2 -6
- package/lib/heatmap/models/heatmap.js +2 -5
- package/lib/index.js +9 -90
- package/lib/line/models/arc.js +4 -4
- package/lib/line/models/arc_3d.js +4 -3
- package/lib/line/models/great_circle.js +4 -4
- package/lib/line/models/line.js +5 -8
- package/lib/line/models/simple_line.js +0 -1
- package/lib/line/models/wall.js +4 -3
- package/lib/plugins/DataMappingPlugin.js +7 -22
- package/lib/plugins/DataSourcePlugin.js +3 -6
- package/lib/plugins/FeatureScalePlugin.js +4 -6
- package/lib/plugins/LayerAnimateStylePlugin.js +2 -5
- package/lib/plugins/LayerMaskPlugin.js +2 -8
- package/lib/plugins/LayerModelPlugin.js +13 -18
- package/lib/plugins/LayerStylePlugin.js +2 -5
- package/lib/plugins/LightingPlugin.js +2 -5
- package/lib/plugins/MultiPassRendererPlugin.js +2 -5
- package/lib/plugins/PixelPickingPlugin.js +4 -9
- package/lib/plugins/RegisterStyleAttributePlugin.js +2 -5
- package/lib/plugins/ShaderUniformPlugin.js +15 -41
- package/lib/plugins/UpdateModelPlugin.js +2 -5
- package/lib/plugins/UpdateStyleAttributePlugin.js +2 -5
- package/lib/plugins/index.js +26 -0
- package/lib/point/models/fill.js +6 -9
- package/lib/point/models/fillImage.js +4 -3
- package/lib/point/models/image.js +4 -3
- package/lib/polygon/models/extrude.js +0 -1
- package/lib/polygon/models/ocean.js +0 -1
- package/lib/polygon/models/water.js +0 -2
- package/lib/tile/core/BaseLayer.js +4 -5
- package/lib/tile/interaction/getRasterData.js +4 -16
- package/lib/tile/service/TileLayerService.js +0 -1
- package/lib/tile/service/TilePickService.js +2 -3
- package/lib/tile/tile/Tile.js +8 -6
- package/lib/tile/utils/utils.js +0 -12
- package/package.json +18 -20
package/es/canvas/index.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type { ILayer } from '@antv/l7-core';
|
|
2
1
|
import BaseLayer from '../core/BaseLayer';
|
|
3
|
-
import type {
|
|
4
|
-
import type { CanvasModelType } from './models
|
|
5
|
-
|
|
2
|
+
import type { ICanvasLayerOptions } from '../core/interface';
|
|
3
|
+
import type { CanvasModelType } from './models';
|
|
4
|
+
import { CanvasModel } from './models';
|
|
5
|
+
export default class CanvasLayer extends BaseLayer<ICanvasLayerOptions> {
|
|
6
6
|
type: string;
|
|
7
|
-
|
|
7
|
+
layerModel: CanvasModel;
|
|
8
|
+
protected getDefaultConfig(): Partial<ICanvasLayerOptions>;
|
|
8
9
|
buildModels(): Promise<void>;
|
|
9
|
-
hide(): ILayer;
|
|
10
|
-
renderModels(): this;
|
|
11
|
-
protected getDefaultConfig(): {};
|
|
12
10
|
getModelType(): CanvasModelType;
|
|
11
|
+
draw(draw: ICanvasLayerOptions['draw']): this;
|
|
12
|
+
getLayerConfig(): any;
|
|
13
|
+
render(): this;
|
|
14
|
+
getCanvas(): HTMLCanvasElement | null;
|
|
15
|
+
show(): this;
|
|
16
|
+
hide(): this;
|
|
17
|
+
destroy(): void;
|
|
13
18
|
}
|
package/es/canvas/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
5
|
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _get from "@babel/runtime/helpers/esm/get";
|
|
5
7
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
8
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
9
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
@@ -9,8 +11,9 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
9
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
13
|
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; } }
|
|
14
|
+
// import type { ILayerConfig } from '@antv/l7-core';
|
|
12
15
|
import BaseLayer from "../core/BaseLayer";
|
|
13
|
-
import
|
|
16
|
+
import { CanvasModel } from "./models";
|
|
14
17
|
var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
15
18
|
_inherits(CanvasLayer, _BaseLayer);
|
|
16
19
|
var _super = _createSuper(CanvasLayer);
|
|
@@ -22,22 +25,28 @@ var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
22
25
|
}
|
|
23
26
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
27
|
_defineProperty(_assertThisInitialized(_this), "type", 'CanvasLayer');
|
|
25
|
-
_defineProperty(_assertThisInitialized(_this), "forceRender", true);
|
|
26
28
|
return _this;
|
|
27
29
|
}
|
|
28
30
|
_createClass(CanvasLayer, [{
|
|
31
|
+
key: "getDefaultConfig",
|
|
32
|
+
value: function getDefaultConfig() {
|
|
33
|
+
return {
|
|
34
|
+
zIndex: 3,
|
|
35
|
+
contextType: 'canvas2d',
|
|
36
|
+
trigger: 'change'
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
29
40
|
key: "buildModels",
|
|
30
41
|
value: function () {
|
|
31
42
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
32
|
-
var modelType;
|
|
33
43
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
34
44
|
while (1) switch (_context.prev = _context.next) {
|
|
35
45
|
case 0:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_context.next = 4;
|
|
46
|
+
this.layerModel = new CanvasModel(this);
|
|
47
|
+
_context.next = 3;
|
|
39
48
|
return this.initLayerModels();
|
|
40
|
-
case
|
|
49
|
+
case 3:
|
|
41
50
|
case "end":
|
|
42
51
|
return _context.stop();
|
|
43
52
|
}
|
|
@@ -49,46 +58,64 @@ var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
49
58
|
return buildModels;
|
|
50
59
|
}()
|
|
51
60
|
}, {
|
|
52
|
-
key: "
|
|
53
|
-
value: function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
key: "getModelType",
|
|
62
|
+
value: function getModelType() {
|
|
63
|
+
return this.getLayerConfig().contextType || 'canvas2d';
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "draw",
|
|
67
|
+
value: function draw(_draw) {
|
|
58
68
|
this.updateLayerConfig({
|
|
59
|
-
|
|
69
|
+
draw: _draw
|
|
60
70
|
});
|
|
61
|
-
this.
|
|
71
|
+
this.render();
|
|
62
72
|
return this;
|
|
63
73
|
}
|
|
64
74
|
}, {
|
|
65
|
-
key: "
|
|
66
|
-
value: function
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.layerModel.renderUpdate();
|
|
75
|
+
key: "getLayerConfig",
|
|
76
|
+
value: function getLayerConfig() {
|
|
77
|
+
var config = _objectSpread(_objectSpread({}, this.getDefaultConfig()), _get(_getPrototypeOf(CanvasLayer.prototype), "getLayerConfig", this).call(this));
|
|
78
|
+
if (config.zIndex < 3) {
|
|
79
|
+
config.zIndex = 3;
|
|
71
80
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
return config;
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "render",
|
|
85
|
+
value: function render() {
|
|
86
|
+
var _this$layerModel;
|
|
87
|
+
(_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.renderCanvas();
|
|
77
88
|
return this;
|
|
78
89
|
}
|
|
79
90
|
}, {
|
|
80
|
-
key: "
|
|
81
|
-
value: function
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
canvas: {}
|
|
85
|
-
};
|
|
86
|
-
return defaultConfig[type];
|
|
91
|
+
key: "getCanvas",
|
|
92
|
+
value: function getCanvas() {
|
|
93
|
+
var _this$layerModel2;
|
|
94
|
+
return (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 ? void 0 : _this$layerModel2.canvas;
|
|
87
95
|
}
|
|
88
96
|
}, {
|
|
89
|
-
key: "
|
|
90
|
-
value: function
|
|
91
|
-
|
|
97
|
+
key: "show",
|
|
98
|
+
value: function show() {
|
|
99
|
+
var canvas = this.getCanvas();
|
|
100
|
+
if (canvas) {
|
|
101
|
+
canvas.style.display = 'unset';
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "hide",
|
|
107
|
+
value: function hide() {
|
|
108
|
+
var canvas = this.getCanvas();
|
|
109
|
+
if (canvas) {
|
|
110
|
+
canvas.style.display = 'none';
|
|
111
|
+
}
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "destroy",
|
|
116
|
+
value: function destroy() {
|
|
117
|
+
this.layerModel.removeCanvas();
|
|
118
|
+
_get(_getPrototypeOf(CanvasLayer.prototype), "destroy", this).call(this);
|
|
92
119
|
}
|
|
93
120
|
}]);
|
|
94
121
|
return CanvasLayer;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import BaseModel from '../../core/BaseModel';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
unBindListener: () => void;
|
|
10
|
-
bindListener: () => void;
|
|
11
|
-
clearModels(): void;
|
|
2
|
+
import { type ICanvasLayerOptions } from '../../core/interface';
|
|
3
|
+
export declare class CanvasModel extends BaseModel {
|
|
4
|
+
canvas: HTMLCanvasElement | null;
|
|
5
|
+
ctx: any;
|
|
6
|
+
ctxType: string;
|
|
7
|
+
viewportSize: [number, number];
|
|
8
|
+
get layerConfig(): ICanvasLayerOptions;
|
|
12
9
|
initModels(): Promise<never[]>;
|
|
13
|
-
initCanvas()
|
|
14
|
-
|
|
10
|
+
initCanvas: () => void;
|
|
11
|
+
resetViewportSize: () => void;
|
|
12
|
+
resetCanvasSize: () => void;
|
|
15
13
|
renderCanvas: () => void;
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
removeCanvas: () => void;
|
|
15
|
+
onMapResize: () => void;
|
|
16
|
+
bindListeners(): void;
|
|
17
|
+
unbindListeners(): void;
|
|
18
|
+
lngLatToContainer: (lngLat: [number, number]) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
registerBuiltinAttributes(): void;
|
|
18
23
|
}
|
|
@@ -12,120 +12,131 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
12
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; } }
|
|
13
13
|
import BaseModel from "../../core/BaseModel";
|
|
14
14
|
import { CanvasUpdateType } from "../../core/interface";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
import { CanvasContextTypeMap } from "./constants";
|
|
16
|
+
export var CanvasModel = /*#__PURE__*/function (_BaseModel) {
|
|
17
|
+
_inherits(CanvasModel, _BaseModel);
|
|
18
|
+
var _super = _createSuper(CanvasModel);
|
|
19
|
+
function CanvasModel() {
|
|
19
20
|
var _this;
|
|
20
|
-
_classCallCheck(this,
|
|
21
|
+
_classCallCheck(this, CanvasModel);
|
|
21
22
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
23
|
args[_key] = arguments[_key];
|
|
23
24
|
}
|
|
24
25
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
26
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
zIndex =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (_this.updateMode === CanvasUpdateType.ALWAYS && animateOption.enable) {
|
|
46
|
-
_this.renderCanvas();
|
|
26
|
+
_defineProperty(_assertThisInitialized(_this), "canvas", null);
|
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "initCanvas", function () {
|
|
28
|
+
var _this$mapService$getC, _this$mapService$getC2, _this$mapService, _this$mapService$getM, _this$mapService2;
|
|
29
|
+
var _this$layerConfig = _this.layerConfig,
|
|
30
|
+
zIndex = _this$layerConfig.zIndex,
|
|
31
|
+
getContext = _this$layerConfig.getContext;
|
|
32
|
+
var canvas = document.createElement('canvas');
|
|
33
|
+
var modelType = _this.layer.getModelType();
|
|
34
|
+
_this.canvas = canvas;
|
|
35
|
+
canvas.classList.add('l7-canvas-layer');
|
|
36
|
+
canvas.style.position = 'absolute';
|
|
37
|
+
canvas.style.top = '0';
|
|
38
|
+
canvas.style.left = '0';
|
|
39
|
+
canvas.style.zIndex = String(zIndex);
|
|
40
|
+
_this.resetCanvasSize();
|
|
41
|
+
var container = (_this$mapService$getC = (_this$mapService$getC2 = (_this$mapService = _this.mapService).getCanvasOverlays) === null || _this$mapService$getC2 === void 0 ? void 0 : _this$mapService$getC2.call(_this$mapService)) !== null && _this$mapService$getC !== void 0 ? _this$mapService$getC : (_this$mapService$getM = (_this$mapService2 = _this.mapService).getMapCanvasContainer) === null || _this$mapService$getM === void 0 ? void 0 : _this$mapService$getM.call(_this$mapService2);
|
|
42
|
+
container === null || container === void 0 || container.appendChild(canvas);
|
|
43
|
+
_this.ctx = getContext ? getContext(canvas) : canvas.getContext(CanvasContextTypeMap[modelType]);
|
|
44
|
+
if (!_this.ctx) {
|
|
45
|
+
console.error('Failed to get rendering context for canvas');
|
|
47
46
|
}
|
|
47
|
+
_this.bindListeners();
|
|
48
48
|
});
|
|
49
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
50
|
-
_this.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_this.
|
|
54
|
-
_this.mapService.off('moveend', _this.renderCanvas);
|
|
55
|
-
});
|
|
56
|
-
_defineProperty(_assertThisInitialized(_this), "bindListener", function () {
|
|
57
|
-
if (_this.updateMode === CanvasUpdateType.ALWAYS) {
|
|
58
|
-
_this.mapService.on('mapchange', _this.renderCanvas);
|
|
59
|
-
} else {
|
|
60
|
-
_this.mapService.on('zoomstart', _this.clearCanvas);
|
|
61
|
-
_this.mapService.on('zoomend', _this.renderCanvas);
|
|
62
|
-
_this.mapService.on('movestart', _this.clearCanvas);
|
|
63
|
-
_this.mapService.on('moveend', _this.renderCanvas);
|
|
64
|
-
}
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "resetViewportSize", function () {
|
|
50
|
+
var _this$rendererService = _this.rendererService.getViewportSize(),
|
|
51
|
+
viewWidth = _this$rendererService.width,
|
|
52
|
+
viewHeight = _this$rendererService.height;
|
|
53
|
+
_this.viewportSize = [viewWidth, viewHeight];
|
|
65
54
|
});
|
|
66
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
h = _this$rendererService.height;
|
|
71
|
-
_this.ctx.clearRect(0, 0, w, h);
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "resetCanvasSize", function () {
|
|
56
|
+
var canvas = _this.canvas;
|
|
57
|
+
if (!canvas) {
|
|
58
|
+
return;
|
|
72
59
|
}
|
|
60
|
+
_this.resetViewportSize();
|
|
61
|
+
var _this$mapService$getS = _this.mapService.getSize(),
|
|
62
|
+
_this$mapService$getS2 = _slicedToArray(_this$mapService$getS, 2),
|
|
63
|
+
width = _this$mapService$getS2[0],
|
|
64
|
+
height = _this$mapService$getS2[1];
|
|
65
|
+
var _this$viewportSize = _slicedToArray(_this.viewportSize, 2),
|
|
66
|
+
viewWidth = _this$viewportSize[0],
|
|
67
|
+
viewHeight = _this$viewportSize[1];
|
|
68
|
+
canvas.width = viewWidth;
|
|
69
|
+
canvas.height = viewHeight;
|
|
70
|
+
canvas.style.width = width + 'px';
|
|
71
|
+
canvas.style.height = height + 'px';
|
|
73
72
|
});
|
|
74
73
|
_defineProperty(_assertThisInitialized(_this), "renderCanvas", function () {
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (_this.prevSize[0] !== viewWidth || _this.prevSize[1] !== viewHeight) {
|
|
79
|
-
_this.prevSize = [viewWidth, viewHeight];
|
|
80
|
-
var size = _this.mapService.getSize();
|
|
81
|
-
var _size = _slicedToArray(size, 2),
|
|
82
|
-
width = _size[0],
|
|
83
|
-
height = _size[1];
|
|
84
|
-
_this.canvas.width = viewWidth;
|
|
85
|
-
_this.canvas.height = viewHeight;
|
|
86
|
-
_this.canvas.style.width = width + 'px';
|
|
87
|
-
_this.canvas.style.height = height + 'px';
|
|
74
|
+
var _ref;
|
|
75
|
+
if (!_this.canvas) {
|
|
76
|
+
_this.initCanvas();
|
|
88
77
|
}
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
var _this$layerConfig2 = _this.layerConfig,
|
|
79
|
+
draw = _this$layerConfig2.draw,
|
|
80
|
+
drawingOnCanvas = _this$layerConfig2.drawingOnCanvas;
|
|
81
|
+
var _this$viewportSize2 = _slicedToArray(_this.viewportSize, 2),
|
|
82
|
+
width = _this$viewportSize2[0],
|
|
83
|
+
height = _this$viewportSize2[1];
|
|
84
|
+
var bounds = _this.mapService.getBounds();
|
|
85
|
+
(_ref = draw !== null && draw !== void 0 ? draw : drawingOnCanvas) === null || _ref === void 0 || _ref({
|
|
86
|
+
canvas: _this.canvas,
|
|
87
|
+
ctx: _this.ctx,
|
|
88
|
+
container: {
|
|
89
|
+
width: width,
|
|
90
|
+
height: height,
|
|
91
|
+
bounds: bounds
|
|
92
|
+
},
|
|
93
|
+
size: [width, height],
|
|
94
|
+
utils: {
|
|
95
|
+
lngLatToContainer: _this.lngLatToContainer
|
|
96
|
+
},
|
|
97
|
+
mapService: _this.mapService
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "removeCanvas", function () {
|
|
101
|
+
if (_this.canvas) {
|
|
102
|
+
var _this$canvas$parentEl;
|
|
103
|
+
(_this$canvas$parentEl = _this.canvas.parentElement) === null || _this$canvas$parentEl === void 0 || _this$canvas$parentEl.removeChild(_this.canvas);
|
|
104
|
+
_this.canvas = null;
|
|
98
105
|
}
|
|
106
|
+
_this.unbindListeners();
|
|
107
|
+
});
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "onMapResize", function () {
|
|
109
|
+
requestAnimationFrame(function () {
|
|
110
|
+
_this.resetCanvasSize();
|
|
111
|
+
_this.renderCanvas();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
_defineProperty(_assertThisInitialized(_this), "lngLatToContainer", function (lngLat) {
|
|
115
|
+
var _this$mapService$lngL = _this.mapService.lngLatToContainer(lngLat),
|
|
116
|
+
x = _this$mapService$lngL.x,
|
|
117
|
+
y = _this$mapService$lngL.y;
|
|
118
|
+
return {
|
|
119
|
+
x: x * window.devicePixelRatio,
|
|
120
|
+
y: y * window.devicePixelRatio
|
|
121
|
+
};
|
|
99
122
|
});
|
|
100
123
|
return _this;
|
|
101
124
|
}
|
|
102
|
-
_createClass(
|
|
103
|
-
key: "
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var _this$mapService$getC;
|
|
107
|
-
(_this$mapService$getC = this.mapService.getContainer()) === null || _this$mapService$getC === void 0 || _this$mapService$getC.removeChild(this.canvas);
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
this.canvas = null;
|
|
110
|
-
}
|
|
111
|
-
this.unBindListener();
|
|
125
|
+
_createClass(CanvasModel, [{
|
|
126
|
+
key: "layerConfig",
|
|
127
|
+
get: function get() {
|
|
128
|
+
return this.layer.getLayerConfig();
|
|
112
129
|
}
|
|
113
130
|
}, {
|
|
114
131
|
key: "initModels",
|
|
115
132
|
value: function () {
|
|
116
133
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
117
|
-
var _ref3, _ref3$update, update;
|
|
118
134
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
119
135
|
while (1) switch (_context.prev = _context.next) {
|
|
120
136
|
case 0:
|
|
121
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$update = _ref3.update, update = _ref3$update === void 0 ? CanvasUpdateType.ALWAYS : _ref3$update;
|
|
122
|
-
this.updateMode = update;
|
|
123
|
-
this.initCanvas();
|
|
124
137
|
this.renderCanvas();
|
|
125
|
-
this.bindListener();
|
|
126
|
-
this.mapService.getContainer();
|
|
127
138
|
return _context.abrupt("return", []);
|
|
128
|
-
case
|
|
139
|
+
case 2:
|
|
129
140
|
case "end":
|
|
130
141
|
return _context.stop();
|
|
131
142
|
}
|
|
@@ -137,59 +148,34 @@ var CanvaModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
137
148
|
return initModels;
|
|
138
149
|
}()
|
|
139
150
|
}, {
|
|
140
|
-
key: "
|
|
141
|
-
value: function
|
|
142
|
-
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.canvas = canvas;
|
|
155
|
-
canvas.width = viewWidth;
|
|
156
|
-
canvas.height = viewHeight;
|
|
157
|
-
canvas.style.pointerEvents = 'none';
|
|
158
|
-
canvas.style.width = width + 'px';
|
|
159
|
-
canvas.style.height = height + 'px';
|
|
160
|
-
canvas.style.position = 'absolute';
|
|
161
|
-
canvas.style.top = '0';
|
|
162
|
-
canvas.style.left = '0';
|
|
163
|
-
canvas.style.zIndex = zIndex + '';
|
|
164
|
-
(_this$mapService$getC2 = this.mapService.getContainer()) === null || _this$mapService$getC2 === void 0 || _this$mapService$getC2.appendChild(canvas);
|
|
165
|
-
var ctx = canvas.getContext('2d');
|
|
166
|
-
this.ctx = ctx;
|
|
151
|
+
key: "bindListeners",
|
|
152
|
+
value: function bindListeners() {
|
|
153
|
+
this.mapService.on('resize', this.onMapResize);
|
|
154
|
+
var _this$layerConfig3 = this.layerConfig,
|
|
155
|
+
trigger = _this$layerConfig3.trigger,
|
|
156
|
+
update = _this$layerConfig3.update;
|
|
157
|
+
if (update === CanvasUpdateType.ALWAYS || trigger === 'change') {
|
|
158
|
+
this.mapService.on('mapchange', this.renderCanvas);
|
|
159
|
+
} else {
|
|
160
|
+
this.mapService.on('zoomstart', this.removeCanvas);
|
|
161
|
+
this.mapService.on('zoomend', this.renderCanvas);
|
|
162
|
+
this.mapService.on('movestart', this.removeCanvas);
|
|
163
|
+
this.mapService.on('moveend', this.renderCanvas);
|
|
164
|
+
}
|
|
167
165
|
}
|
|
168
166
|
}, {
|
|
169
|
-
key: "
|
|
170
|
-
value: function () {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return _context2.stop();
|
|
179
|
-
}
|
|
180
|
-
}, _callee2, this);
|
|
181
|
-
}));
|
|
182
|
-
function buildModels() {
|
|
183
|
-
return _buildModels.apply(this, arguments);
|
|
184
|
-
}
|
|
185
|
-
return buildModels;
|
|
186
|
-
}()
|
|
167
|
+
key: "unbindListeners",
|
|
168
|
+
value: function unbindListeners() {
|
|
169
|
+
this.mapService.off('resize', this.onMapResize);
|
|
170
|
+
this.mapService.off('mapchange', this.renderCanvas);
|
|
171
|
+
this.mapService.off('zoomstart', this.removeCanvas);
|
|
172
|
+
this.mapService.off('zoomend', this.renderCanvas);
|
|
173
|
+
this.mapService.off('movestart', this.removeCanvas);
|
|
174
|
+
this.mapService.off('moveend', this.renderCanvas);
|
|
175
|
+
}
|
|
187
176
|
}, {
|
|
188
177
|
key: "registerBuiltinAttributes",
|
|
189
|
-
value: function registerBuiltinAttributes() {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
178
|
+
value: function registerBuiltinAttributes() {}
|
|
192
179
|
}]);
|
|
193
|
-
return
|
|
194
|
-
}(BaseModel);
|
|
195
|
-
export { CanvaModel as default };
|
|
180
|
+
return CanvasModel;
|
|
181
|
+
}(BaseModel);
|
package/es/core/BaseLayer.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
|
|
2
|
-
import type { IActiveOption, IAnimateOption, IAttributeAndElements, IBuffer,
|
|
2
|
+
import type { IActiveOption, IAnimateOption, IAttributeAndElements, IBuffer, IDataState, IEncodeFeature, IGlobalConfigService, ILayer, ILayerAttributesOption, ILayerConfig, ILayerModel, ILayerModelInitializationOptions, ILayerPickService, ILayerPlugin, ILegend, IModel, IModelInitializationOptions, IMultiPassRenderer, IParseDataItem, IPostProcessingPass, IRenderOptions, IScale, IScaleOptions, ISourceCFG, IStyleAttributeService, IStyleAttributeUpdateOptions, ITextureService, L7Container, LayerEventType, LegendItems, StyleAttributeField, StyleAttributeOption, Triangulation } from '@antv/l7-core';
|
|
3
3
|
import { BlendType } from '@antv/l7-core';
|
|
4
|
-
import Source from '@antv/l7-source';
|
|
4
|
+
import type Source from '@antv/l7-source';
|
|
5
5
|
import { EventEmitter } from 'eventemitter3';
|
|
6
|
-
import type { Container } from 'inversify';
|
|
7
6
|
export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter<LayerEventType> implements ILayer {
|
|
8
7
|
id: string;
|
|
9
8
|
name: string;
|
|
@@ -59,31 +58,30 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
59
58
|
field: any;
|
|
60
59
|
values: any;
|
|
61
60
|
};
|
|
62
|
-
sceneContainer: Container | undefined;
|
|
63
61
|
tileLayer: any | undefined;
|
|
64
62
|
layerChildren: ILayer[];
|
|
65
63
|
masks: ILayer[];
|
|
66
64
|
protected readonly configService: IGlobalConfigService;
|
|
67
|
-
protected shaderModuleService: IShaderModuleService;
|
|
68
|
-
protected cameraService: ICameraService;
|
|
69
|
-
protected coordinateService: ICoordinateSystemService;
|
|
70
|
-
protected iconService: IIconService;
|
|
71
|
-
protected fontService: IFontService;
|
|
72
|
-
protected pickingService: IPickingService;
|
|
73
|
-
protected rendererService: IRendererService;
|
|
74
|
-
protected layerService: ILayerService;
|
|
75
|
-
protected debugService: IDebugService;
|
|
76
|
-
protected interactionService:
|
|
77
|
-
protected mapService: IMapService
|
|
65
|
+
protected get shaderModuleService(): import("@antv/l7-core").IShaderModuleService;
|
|
66
|
+
protected get cameraService(): import("@antv/l7-core").ICameraService;
|
|
67
|
+
protected get coordinateService(): import("@antv/l7-core").ICoordinateSystemService;
|
|
68
|
+
protected get iconService(): import("@antv/l7-core").IIconService;
|
|
69
|
+
protected get fontService(): import("@antv/l7-core").IFontService;
|
|
70
|
+
protected get pickingService(): import("@antv/l7-core").IPickingService;
|
|
71
|
+
protected get rendererService(): import("@antv/l7-core").IRendererService;
|
|
72
|
+
protected get layerService(): import("@antv/l7-core").ILayerService;
|
|
73
|
+
protected get debugService(): import("@antv/l7-core").IDebugService;
|
|
74
|
+
protected get interactionService(): import("@antv/l7-core/es/services/interaction/InteractionService").default;
|
|
75
|
+
protected get mapService(): import("@antv/l7-core").IMapService<{}>;
|
|
78
76
|
styleAttributeService: IStyleAttributeService;
|
|
79
77
|
protected layerSource: Source;
|
|
80
78
|
postProcessingPassFactory: (name: string) => IPostProcessingPass<unknown>;
|
|
81
|
-
normalPassFactory: (name: string) => IPass<unknown>;
|
|
79
|
+
get normalPassFactory(): (name: string) => import("@antv/l7-core").IPass<unknown>;
|
|
82
80
|
protected animateOptions: IAnimateOption;
|
|
83
81
|
/**
|
|
84
82
|
* 图层容器
|
|
85
83
|
*/
|
|
86
|
-
|
|
84
|
+
container: L7Container;
|
|
87
85
|
private encodedData;
|
|
88
86
|
private currentPickId;
|
|
89
87
|
protected rawConfig: Partial<ILayerConfig & ChildLayerStyleOptions>;
|
|
@@ -130,8 +128,8 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
130
128
|
* -> SceneContainer 1.*
|
|
131
129
|
* -> LayerContainer 1.*
|
|
132
130
|
*/
|
|
133
|
-
setContainer(container:
|
|
134
|
-
getContainer():
|
|
131
|
+
setContainer(container: L7Container): void;
|
|
132
|
+
getContainer(): L7Container;
|
|
135
133
|
addPlugin(plugin: ILayerPlugin): ILayer;
|
|
136
134
|
init(): Promise<void>;
|
|
137
135
|
log(logType: string, step?: string): void;
|