@antv/l7-layers 2.8.3 → 2.8.6

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.
Files changed (44) hide show
  1. package/es/canvas/index.d.ts +19 -0
  2. package/es/canvas/index.js +82 -0
  3. package/es/canvas/index.js.map +1 -0
  4. package/es/canvas/models/canvas.d.ts +18 -0
  5. package/es/canvas/models/canvas.js +202 -0
  6. package/es/canvas/models/canvas.js.map +1 -0
  7. package/es/canvas/models/index.d.ts +5 -0
  8. package/es/canvas/models/index.js +6 -0
  9. package/es/canvas/models/index.js.map +1 -0
  10. package/es/core/BaseLayer.js +4 -0
  11. package/es/core/BaseLayer.js.map +1 -1
  12. package/es/core/interface.d.ts +12 -1
  13. package/es/core/interface.js +7 -0
  14. package/es/core/interface.js.map +1 -1
  15. package/es/index.d.ts +2 -1
  16. package/es/index.js +2 -1
  17. package/es/index.js.map +1 -1
  18. package/es/polygon/index.js +2 -0
  19. package/es/polygon/index.js.map +1 -1
  20. package/es/polygon/models/index.d.ts +1 -1
  21. package/es/polygon/models/index.js +3 -1
  22. package/es/polygon/models/index.js.map +1 -1
  23. package/es/polygon/models/ocean.d.ts +23 -0
  24. package/es/polygon/models/ocean.js +238 -0
  25. package/es/polygon/models/ocean.js.map +1 -0
  26. package/lib/canvas/index.js +95 -0
  27. package/lib/canvas/index.js.map +1 -0
  28. package/lib/canvas/models/canvas.js +208 -0
  29. package/lib/canvas/models/canvas.js.map +1 -0
  30. package/lib/canvas/models/index.js +17 -0
  31. package/lib/canvas/models/index.js.map +1 -0
  32. package/lib/core/BaseLayer.js +4 -0
  33. package/lib/core/BaseLayer.js.map +1 -1
  34. package/lib/core/interface.js +9 -1
  35. package/lib/core/interface.js.map +1 -1
  36. package/lib/index.js +8 -0
  37. package/lib/index.js.map +1 -1
  38. package/lib/polygon/index.js +2 -0
  39. package/lib/polygon/index.js.map +1 -1
  40. package/lib/polygon/models/index.js +4 -1
  41. package/lib/polygon/models/index.js.map +1 -1
  42. package/lib/polygon/models/ocean.js +254 -0
  43. package/lib/polygon/models/ocean.js.map +1 -0
  44. package/package.json +5 -5
@@ -0,0 +1,19 @@
1
+ import BaseLayer from '../core/BaseLayer';
2
+ import { ICanvasLayerStyleOptions } from '../core/interface';
3
+ import { CanvasModelType } from './models/index';
4
+ export default class CanvasLayer extends BaseLayer<ICanvasLayerStyleOptions> {
5
+ type: string;
6
+ buildModels(): void;
7
+ rebuildModels(): void;
8
+ protected getConfigSchema(): {
9
+ properties: {
10
+ opacity: {
11
+ type: string;
12
+ minimum: number;
13
+ maximum: number;
14
+ };
15
+ };
16
+ };
17
+ protected getDefaultConfig(): {};
18
+ protected getModelType(): CanvasModelType;
19
+ }
@@ -0,0 +1,82 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ 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); }; }
10
+
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
+
13
+ import BaseLayer from '../core/BaseLayer';
14
+ import CanvasModels from './models/index';
15
+
16
+ var CanvasLayer = function (_BaseLayer) {
17
+ _inherits(CanvasLayer, _BaseLayer);
18
+
19
+ var _super = _createSuper(CanvasLayer);
20
+
21
+ function CanvasLayer() {
22
+ var _this;
23
+
24
+ _classCallCheck(this, CanvasLayer);
25
+
26
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
+ args[_key] = arguments[_key];
28
+ }
29
+
30
+ _this = _super.call.apply(_super, [this].concat(args));
31
+
32
+ _defineProperty(_assertThisInitialized(_this), "type", 'CanvasLayer');
33
+
34
+ return _this;
35
+ }
36
+
37
+ _createClass(CanvasLayer, [{
38
+ key: "buildModels",
39
+ value: function buildModels() {
40
+ var modelType = this.getModelType();
41
+ this.layerModel = new CanvasModels[modelType](this);
42
+ this.models = this.layerModel.initModels();
43
+ }
44
+ }, {
45
+ key: "rebuildModels",
46
+ value: function rebuildModels() {
47
+ this.models = this.layerModel.buildModels();
48
+ }
49
+ }, {
50
+ key: "getConfigSchema",
51
+ value: function getConfigSchema() {
52
+ return {
53
+ properties: {
54
+ opacity: {
55
+ type: 'number',
56
+ minimum: 0,
57
+ maximum: 1
58
+ }
59
+ }
60
+ };
61
+ }
62
+ }, {
63
+ key: "getDefaultConfig",
64
+ value: function getDefaultConfig() {
65
+ var type = this.getModelType();
66
+ var defaultConfig = {
67
+ canvas: {}
68
+ };
69
+ return defaultConfig[type];
70
+ }
71
+ }, {
72
+ key: "getModelType",
73
+ value: function getModelType() {
74
+ return 'canvas';
75
+ }
76
+ }]);
77
+
78
+ return CanvasLayer;
79
+ }(BaseLayer);
80
+
81
+ export { CanvasLayer as default };
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/canvas/index.ts"],"names":["BaseLayer","CanvasModels","CanvasLayer","modelType","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","canvas"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,YAAP,MAA8C,gBAA9C;;IACqBC,W;;;;;;;;;;;;;;;;2DACG,a;;;;;;;WACtB,uBAAqB;AACnB,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;AACA,WAAKC,UAAL,GAAkB,IAAIJ,YAAY,CAACE,SAAD,CAAhB,CAA4B,IAA5B,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WACD,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKP,YAAL,EAAb;AACA,UAAMU,aAAa,GAAG;AACpBC,QAAAA,MAAM,EAAE;AADY,OAAtB;AAGA,aAAOD,aAAa,CAACH,IAAD,CAApB;AACD;;;WAED,wBAA0C;AACxC,aAAO,QAAP;AACD;;;;EA/BsCX,S;;SAApBE,W","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { ICanvasLayerStyleOptions } from '../core/interface';\nimport CanvasModels, { CanvasModelType } from './models/index';\nexport default class CanvasLayer extends BaseLayer<ICanvasLayerStyleOptions> {\n public type: string = 'CanvasLayer';\n public buildModels() {\n const modelType = this.getModelType();\n this.layerModel = new CanvasModels[modelType](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n protected getDefaultConfig() {\n const type = this.getModelType();\n const defaultConfig = {\n canvas: {},\n };\n return defaultConfig[type];\n }\n\n protected getModelType(): CanvasModelType {\n return 'canvas';\n }\n}\n"],"file":"index.js"}
@@ -0,0 +1,18 @@
1
+ import BaseModel from '../../core/BaseModel';
2
+ import { CanvasUpdateType } from '../../core/interface';
3
+ export default class CanvaModel extends BaseModel {
4
+ protected updateMode: CanvasUpdateType;
5
+ protected canvas: HTMLCanvasElement;
6
+ protected ctx: CanvasRenderingContext2D;
7
+ protected prevSize: [number, number];
8
+ renderUpdate: () => void;
9
+ unBindListener: () => void;
10
+ bindListener: () => void;
11
+ clearModels(): void;
12
+ initModels(): never[];
13
+ initCanvas(): void;
14
+ clearCanvas: () => void;
15
+ renderCanvas: () => void;
16
+ buildModels(): never[];
17
+ protected registerBuiltinAttributes(): void;
18
+ }
@@ -0,0 +1,202 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
+
10
+ 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
+
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
+
14
+ import BaseModel from '../../core/BaseModel';
15
+ import { CanvasUpdateType } from '../../core/interface';
16
+
17
+ var CanvaModel = function (_BaseModel) {
18
+ _inherits(CanvaModel, _BaseModel);
19
+
20
+ var _super = _createSuper(CanvaModel);
21
+
22
+ function CanvaModel() {
23
+ var _this;
24
+
25
+ _classCallCheck(this, CanvaModel);
26
+
27
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ args[_key] = arguments[_key];
29
+ }
30
+
31
+ _this = _super.call.apply(_super, [this].concat(args));
32
+
33
+ _defineProperty(_assertThisInitialized(_this), "updateMode", CanvasUpdateType.AWAYS);
34
+
35
+ _defineProperty(_assertThisInitialized(_this), "canvas", void 0);
36
+
37
+ _defineProperty(_assertThisInitialized(_this), "ctx", void 0);
38
+
39
+ _defineProperty(_assertThisInitialized(_this), "prevSize", void 0);
40
+
41
+ _defineProperty(_assertThisInitialized(_this), "renderUpdate", function () {
42
+ var _ref = _this.layer.getLayerConfig(),
43
+ _ref$zIndex = _ref.zIndex,
44
+ zIndex = _ref$zIndex === void 0 ? 10 : _ref$zIndex,
45
+ _ref$update = _ref.update,
46
+ update = _ref$update === void 0 ? CanvasUpdateType.AWAYS : _ref$update;
47
+
48
+ if (+_this.canvas.style.zIndex === zIndex) {
49
+ _this.canvas.style.zIndex = zIndex + '';
50
+ }
51
+
52
+ if (_this.updateMode !== update) {
53
+ _this.updateMode = update;
54
+
55
+ _this.unBindListener();
56
+
57
+ _this.bindListener();
58
+ }
59
+ });
60
+
61
+ _defineProperty(_assertThisInitialized(_this), "unBindListener", function () {
62
+ _this.mapService.off('mapchange', _this.renderCanvas);
63
+
64
+ _this.mapService.off('zoomstart', _this.clearCanvas);
65
+
66
+ _this.mapService.off('zoomend', _this.renderCanvas);
67
+
68
+ _this.mapService.off('movestart', _this.clearCanvas);
69
+
70
+ _this.mapService.off('moveend', _this.renderCanvas);
71
+ });
72
+
73
+ _defineProperty(_assertThisInitialized(_this), "bindListener", function () {
74
+ if (_this.updateMode === CanvasUpdateType.AWAYS) {
75
+ _this.mapService.on('mapchange', _this.renderCanvas);
76
+ } else {
77
+ _this.mapService.on('zoomstart', _this.clearCanvas);
78
+
79
+ _this.mapService.on('zoomend', _this.renderCanvas);
80
+
81
+ _this.mapService.on('movestart', _this.clearCanvas);
82
+
83
+ _this.mapService.on('moveend', _this.renderCanvas);
84
+ }
85
+ });
86
+
87
+ _defineProperty(_assertThisInitialized(_this), "clearCanvas", function () {
88
+ if (_this.ctx) {
89
+ var _this$rendererService = _this.rendererService.getViewportSize(),
90
+ w = _this$rendererService.width,
91
+ h = _this$rendererService.height;
92
+
93
+ _this.ctx.clearRect(0, 0, w, h);
94
+ }
95
+ });
96
+
97
+ _defineProperty(_assertThisInitialized(_this), "renderCanvas", function () {
98
+ var _this$rendererService2 = _this.rendererService.getViewportSize(),
99
+ viewWidth = _this$rendererService2.width,
100
+ viewHeight = _this$rendererService2.height;
101
+
102
+ if (_this.prevSize[0] !== viewWidth || _this.prevSize[1] !== viewHeight) {
103
+ _this.prevSize = [viewWidth, viewHeight];
104
+
105
+ var size = _this.mapService.getSize();
106
+
107
+ var _size = _slicedToArray(size, 2),
108
+ width = _size[0],
109
+ height = _size[1];
110
+
111
+ _this.canvas.width = viewWidth;
112
+ _this.canvas.height = viewHeight;
113
+ _this.canvas.style.width = width + 'px';
114
+ _this.canvas.style.height = height + 'px';
115
+ }
116
+
117
+ var _ref2 = _this.layer.getLayerConfig(),
118
+ drawingOnCanvas = _ref2.drawingOnCanvas;
119
+
120
+ if (_this.ctx) {
121
+ drawingOnCanvas(_this.ctx, _this.mapService, [viewWidth, viewHeight]);
122
+ }
123
+ });
124
+
125
+ return _this;
126
+ }
127
+
128
+ _createClass(CanvaModel, [{
129
+ key: "clearModels",
130
+ value: function clearModels() {
131
+ if (this.canvas) {
132
+ document.removeChild(this.canvas);
133
+ this.canvas = null;
134
+ }
135
+
136
+ this.unBindListener();
137
+ }
138
+ }, {
139
+ key: "initModels",
140
+ value: function initModels() {
141
+ var _ref3 = this.layer.getLayerConfig(),
142
+ _ref3$update = _ref3.update,
143
+ update = _ref3$update === void 0 ? CanvasUpdateType.AWAYS : _ref3$update;
144
+
145
+ this.updateMode = update;
146
+ this.initCanvas();
147
+ this.renderCanvas();
148
+ this.bindListener();
149
+ this.mapService.getContainer();
150
+ return [];
151
+ }
152
+ }, {
153
+ key: "initCanvas",
154
+ value: function initCanvas() {
155
+ var _this$mapService$getC;
156
+
157
+ var _ref4 = this.layer.getLayerConfig(),
158
+ zIndex = _ref4.zIndex;
159
+
160
+ var size = this.mapService.getSize();
161
+
162
+ var _size2 = _slicedToArray(size, 2),
163
+ width = _size2[0],
164
+ height = _size2[1];
165
+
166
+ var _this$rendererService3 = this.rendererService.getViewportSize(),
167
+ viewWidth = _this$rendererService3.width,
168
+ viewHeight = _this$rendererService3.height;
169
+
170
+ this.prevSize = [viewWidth, viewHeight];
171
+ var canvas = document.createElement('canvas');
172
+ this.canvas = canvas;
173
+ canvas.width = viewWidth;
174
+ canvas.height = viewHeight;
175
+ canvas.style.pointerEvents = 'none';
176
+ canvas.style.width = width + 'px';
177
+ canvas.style.height = height + 'px';
178
+ canvas.style.position = 'absolute';
179
+ canvas.style.top = '0';
180
+ canvas.style.left = '0';
181
+ canvas.style.zIndex = zIndex + '';
182
+ (_this$mapService$getC = this.mapService.getContainer()) === null || _this$mapService$getC === void 0 ? void 0 : _this$mapService$getC.appendChild(canvas);
183
+ var ctx = canvas.getContext('2d');
184
+ this.ctx = ctx;
185
+ }
186
+ }, {
187
+ key: "buildModels",
188
+ value: function buildModels() {
189
+ return this.initModels();
190
+ }
191
+ }, {
192
+ key: "registerBuiltinAttributes",
193
+ value: function registerBuiltinAttributes() {
194
+ return;
195
+ }
196
+ }]);
197
+
198
+ return CanvaModel;
199
+ }(BaseModel);
200
+
201
+ export { CanvaModel as default };
202
+ //# sourceMappingURL=canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/canvas/models/canvas.ts"],"names":["BaseModel","CanvasUpdateType","CanvaModel","AWAYS","layer","getLayerConfig","zIndex","update","canvas","style","updateMode","unBindListener","bindListener","mapService","off","renderCanvas","clearCanvas","on","ctx","rendererService","getViewportSize","w","width","h","height","clearRect","viewWidth","viewHeight","prevSize","size","getSize","drawingOnCanvas","document","removeChild","initCanvas","getContainer","createElement","pointerEvents","position","top","left","appendChild","getContext","initModels"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,sBAAtB;AACA,SACEC,gBADF,QAGO,sBAHP;;IAKqBC,U;;;;;;;;;;;;;;;;iEACsBD,gBAAgB,CAACE,K;;;;;;;;mEAIpC,YAAM;AAC1B,iBAGI,MAAKC,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEC,MADF;AAAA,UACEA,MADF,4BACW,EADX;AAAA,6BAEEC,MAFF;AAAA,UAEEA,MAFF,4BAEWN,gBAAgB,CAACE,KAF5B;;AAIA,UAAI,CAAC,MAAKK,MAAL,CAAYC,KAAZ,CAAkBH,MAAnB,KAA8BA,MAAlC,EAA0C;AACxC,cAAKE,MAAL,CAAYC,KAAZ,CAAkBH,MAAlB,GAA2BA,MAAM,GAAG,EAApC;AACD;;AACD,UAAI,MAAKI,UAAL,KAAoBH,MAAxB,EAAgC;AAC9B,cAAKG,UAAL,GAAkBH,MAAlB;;AACA,cAAKI,cAAL;;AACA,cAAKC,YAAL;AACD;AACF,K;;qEAEuB,YAAM;AAC5B,YAAKC,UAAL,CAAgBC,GAAhB,CAAoB,WAApB,EAAiC,MAAKC,YAAtC;;AACA,YAAKF,UAAL,CAAgBC,GAAhB,CAAoB,WAApB,EAAiC,MAAKE,WAAtC;;AACA,YAAKH,UAAL,CAAgBC,GAAhB,CAAoB,SAApB,EAA+B,MAAKC,YAApC;;AACA,YAAKF,UAAL,CAAgBC,GAAhB,CAAoB,WAApB,EAAiC,MAAKE,WAAtC;;AACA,YAAKH,UAAL,CAAgBC,GAAhB,CAAoB,SAApB,EAA+B,MAAKC,YAApC;AACD,K;;mEAEqB,YAAM;AAC1B,UAAI,MAAKL,UAAL,KAAo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M,GAAGwB,QAAQ,CAACI,aAAT,CAAuB,QAAvB,CAAf;AACA,WAAK5B,MAAL,GAAcA,MAAd;AACAA,MAAAA,MAAM,CAACc,KAAP,GAAeI,SAAf;AACAlB,MAAAA,MAAM,CAACgB,MAAP,GAAgBG,UAAhB;AACAnB,MAAAA,MAAM,CAACC,KAAP,CAAa4B,aAAb,GAA6B,MAA7B;AACA7B,MAAAA,MAAM,CAACC,KAAP,CAAaa,KAAb,GAAqBA,KAAK,GAAG,IAA7B;AACAd,MAAAA,MAAM,CAACC,KAAP,CAAae,MAAb,GAAsBA,MAAM,GAAG,IAA/B;AACAhB,MAAAA,MAAM,CAACC,KAAP,CAAa6B,QAAb,GAAwB,UAAxB;AACA9B,MAAAA,MAAM,CAACC,KAAP,CAAa8B,GAAb,GAAmB,GAAnB;AACA/B,MAAAA,MAAM,CAACC,KAAP,CAAa+B,IAAb,GAAoB,GAApB;AACAhC,MAAAA,MAAM,CAACC,KAAP,CAAaH,MAAb,GAAsBA,MAAM,GAAG,EAA/B;AACA,oCAAKO,UAAL,CAAgBsB,YAAhB,kFAAgCM,WAAhC,CAA4CjC,MAA5C;AAEA,UAAMU,GAAG,GAAGV,MAAM,CAACkC,UAAP,CAAkB,IAAlB,CAAZ;AACA,WAAKxB,GAAL,GAAWA,GAAX;AACD;;;WAiCD,uBAAqB;AACnB,aAAO,KAAKyB,UAAL,EAAP;AACD;;;WAED,qCAAsC;AACpC;AACD;;;;EA/HqC3C,S;;SAAnBE,U","sourcesContent":["import BaseModel from '../../core/BaseModel';\nimport {\n CanvasUpdateType,\n ICanvasLayerStyleOptions,\n} from '../../core/interface';\n\nexport default class CanvaModel extends BaseModel {\n protected updateMode: CanvasUpdateType = CanvasUpdateType.AWAYS;\n protected canvas: HTMLCanvasElement;\n protected ctx: CanvasRenderingContext2D;\n protected prevSize: [number, number];\n public renderUpdate = () => {\n const {\n zIndex = 10,\n update = CanvasUpdateType.AWAYS,\n } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n if (+this.canvas.style.zIndex === zIndex) {\n this.canvas.style.zIndex = zIndex + '';\n }\n if (this.updateMode !== update) {\n this.updateMode = update as CanvasUpdateType;\n this.unBindListener();\n this.bindListener();\n }\n };\n\n public unBindListener = () => {\n this.mapService.off('mapchange', this.renderCanvas);\n this.mapService.off('zoomstart', this.clearCanvas);\n this.mapService.off('zoomend', this.renderCanvas);\n this.mapService.off('movestart', this.clearCanvas);\n this.mapService.off('moveend', this.renderCanvas);\n };\n\n public bindListener = () => {\n if (this.updateMode === CanvasUpdateType.AWAYS) {\n this.mapService.on('mapchange', this.renderCanvas);\n } else {\n this.mapService.on('zoomstart', this.clearCanvas);\n this.mapService.on('zoomend', this.renderCanvas);\n this.mapService.on('movestart', this.clearCanvas);\n this.mapService.on('moveend', this.renderCanvas);\n }\n };\n\n public clearModels(): void {\n if (this.canvas) {\n document.removeChild(this.canvas);\n // @ts-ignore\n this.canvas = null;\n }\n this.unBindListener();\n }\n\n public initModels() {\n const {\n update = CanvasUpdateType.AWAYS,\n } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n this.updateMode = update as CanvasUpdateType;\n this.initCanvas();\n\n this.renderCanvas();\n\n this.bindListener();\n\n this.mapService.getContainer();\n return [];\n }\n\n public initCanvas(): void {\n const { zIndex } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n const size = this.mapService.getSize();\n const [width, height] = size;\n const {\n width: viewWidth,\n height: viewHeight,\n } = this.rendererService.getViewportSize();\n this.prevSize = [viewWidth, viewHeight];\n\n const canvas = document.createElement('canvas');\n this.canvas = canvas;\n canvas.width = viewWidth;\n canvas.height = viewHeight;\n canvas.style.pointerEvents = 'none';\n canvas.style.width = width + 'px';\n canvas.style.height = height + 'px';\n canvas.style.position = 'absolute';\n canvas.style.top = '0';\n canvas.style.left = '0';\n canvas.style.zIndex = zIndex + '';\n this.mapService.getContainer()?.appendChild(canvas);\n\n const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;\n this.ctx = ctx;\n }\n\n public clearCanvas = () => {\n if (this.ctx) {\n const { width: w, height: h } = this.rendererService.getViewportSize();\n this.ctx.clearRect(0, 0, w, h);\n }\n };\n\n public renderCanvas = () => {\n const {\n width: viewWidth,\n height: viewHeight,\n } = this.rendererService.getViewportSize();\n if (this.prevSize[0] !== viewWidth || this.prevSize[1] !== viewHeight) {\n this.prevSize = [viewWidth, viewHeight];\n const size = this.mapService.getSize();\n const [width, height] = size;\n this.canvas.width = viewWidth;\n this.canvas.height = viewHeight;\n this.canvas.style.width = width + 'px';\n this.canvas.style.height = height + 'px';\n }\n\n const {\n drawingOnCanvas,\n } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n\n if (this.ctx) {\n drawingOnCanvas(this.ctx, this.mapService, [viewWidth, viewHeight]);\n }\n };\n\n public buildModels() {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n return;\n }\n}\n"],"file":"canvas.js"}
@@ -0,0 +1,5 @@
1
+ export declare type CanvasModelType = 'canvas';
2
+ declare const CanvasModels: {
3
+ [key in CanvasModelType]: any;
4
+ };
5
+ export default CanvasModels;
@@ -0,0 +1,6 @@
1
+ import CanvasModel from './canvas';
2
+ var CanvasModels = {
3
+ canvas: CanvasModel
4
+ };
5
+ export default CanvasModels;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/canvas/models/index.ts"],"names":["CanvasModel","CanvasModels","canvas"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,UAAxB;AAGA,IAAMC,YAA+C,GAAG;AACtDC,EAAAA,MAAM,EAAEF;AAD8C,CAAxD;AAIA,eAAeC,YAAf","sourcesContent":["import CanvasModel from './canvas';\nexport type CanvasModelType = 'canvas';\n\nconst CanvasModels: { [key in CanvasModelType]: any } = {\n canvas: CanvasModel,\n};\n\nexport default CanvasModels;\n"],"file":"index.js"}
@@ -1097,6 +1097,10 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = functi
1097
1097
  this.layerModelNeedUpdate = false;
1098
1098
  }
1099
1099
 
1100
+ if (this.layerModel.renderUpdate) {
1101
+ this.layerModel.renderUpdate();
1102
+ }
1103
+
1100
1104
  this.models.forEach(function (model) {
1101
1105
  model.draw({
1102
1106
  uniforms: _this7.layerModel.getUninforms()