@antv/l7-layers 2.20.20 → 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 +0 -2
- 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/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 +0 -2
- 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/package.json +18 -20
package/es/tile/tile/Tile.js
CHANGED
|
@@ -118,8 +118,8 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
118
118
|
}).shape('fill').color('#0f0').style({
|
|
119
119
|
opacity: 0.5
|
|
120
120
|
});
|
|
121
|
-
container = createLayerContainer(this.parent.
|
|
122
|
-
mask.setContainer(container
|
|
121
|
+
container = createLayerContainer(this.parent.container);
|
|
122
|
+
mask.setContainer(container);
|
|
123
123
|
_context.next = 5;
|
|
124
124
|
return mask.init();
|
|
125
125
|
case 5:
|
|
@@ -148,8 +148,8 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
148
148
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
149
149
|
while (1) switch (_context2.prev = _context2.next) {
|
|
150
150
|
case 0:
|
|
151
|
-
container = createLayerContainer(this.parent.
|
|
152
|
-
mask.setContainer(container
|
|
151
|
+
container = createLayerContainer(this.parent.container);
|
|
152
|
+
mask.setContainer(container);
|
|
153
153
|
_context2.next = 4;
|
|
154
154
|
return mask.init();
|
|
155
155
|
case 4:
|
|
@@ -176,8 +176,8 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
176
176
|
case 0:
|
|
177
177
|
// set flag
|
|
178
178
|
layer.isTileLayer = true;
|
|
179
|
-
container = createLayerContainer(this.parent.
|
|
180
|
-
layer.setContainer(container
|
|
179
|
+
container = createLayerContainer(this.parent.container);
|
|
180
|
+
layer.setContainer(container);
|
|
181
181
|
this.layers.push(layer);
|
|
182
182
|
_context3.next = 6;
|
|
183
183
|
return layer.init();
|
|
@@ -214,6 +214,7 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
214
214
|
value: function getMainLayer() {
|
|
215
215
|
return this.layers[0];
|
|
216
216
|
}
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
217
218
|
}, {
|
|
218
219
|
key: "getFeatures",
|
|
219
220
|
value: function getFeatures(sourceLayer) {
|
|
@@ -225,6 +226,7 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
225
226
|
* @param id
|
|
226
227
|
* @returns
|
|
227
228
|
*/
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
228
230
|
}, {
|
|
229
231
|
key: "getFeatureById",
|
|
230
232
|
value: function getFeatureById(id) {
|
package/lib/canvas/index.js
CHANGED
|
@@ -6,18 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
13
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
15
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
16
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
17
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
19
|
var _BaseLayer2 = _interopRequireDefault(require("../core/BaseLayer"));
|
|
18
|
-
var
|
|
20
|
+
var _models = require("./models");
|
|
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
|
-
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; } }
|
|
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; } } // import type { ILayerConfig } from '@antv/l7-core';
|
|
21
23
|
var CanvasLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
|
|
22
24
|
(0, _inherits2.default)(CanvasLayer, _BaseLayer);
|
|
23
25
|
var _super = _createSuper(CanvasLayer);
|
|
@@ -29,22 +31,28 @@ var CanvasLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
|
|
|
29
31
|
}
|
|
30
32
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
33
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'CanvasLayer');
|
|
32
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "forceRender", true);
|
|
33
34
|
return _this;
|
|
34
35
|
}
|
|
35
36
|
(0, _createClass2.default)(CanvasLayer, [{
|
|
37
|
+
key: "getDefaultConfig",
|
|
38
|
+
value: function getDefaultConfig() {
|
|
39
|
+
return {
|
|
40
|
+
zIndex: 3,
|
|
41
|
+
contextType: 'canvas2d',
|
|
42
|
+
trigger: 'change'
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
36
46
|
key: "buildModels",
|
|
37
47
|
value: function () {
|
|
38
48
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
39
|
-
var modelType;
|
|
40
49
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
50
|
while (1) switch (_context.prev = _context.next) {
|
|
42
51
|
case 0:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_context.next = 4;
|
|
52
|
+
this.layerModel = new _models.CanvasModel(this);
|
|
53
|
+
_context.next = 3;
|
|
46
54
|
return this.initLayerModels();
|
|
47
|
-
case
|
|
55
|
+
case 3:
|
|
48
56
|
case "end":
|
|
49
57
|
return _context.stop();
|
|
50
58
|
}
|
|
@@ -56,46 +64,64 @@ var CanvasLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
|
|
|
56
64
|
return buildModels;
|
|
57
65
|
}()
|
|
58
66
|
}, {
|
|
59
|
-
key: "
|
|
60
|
-
value: function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
key: "getModelType",
|
|
68
|
+
value: function getModelType() {
|
|
69
|
+
return this.getLayerConfig().contextType || 'canvas2d';
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "draw",
|
|
73
|
+
value: function draw(_draw) {
|
|
65
74
|
this.updateLayerConfig({
|
|
66
|
-
|
|
75
|
+
draw: _draw
|
|
67
76
|
});
|
|
68
|
-
this.
|
|
77
|
+
this.render();
|
|
69
78
|
return this;
|
|
70
79
|
}
|
|
71
80
|
}, {
|
|
72
|
-
key: "
|
|
73
|
-
value: function
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.layerModel.renderUpdate();
|
|
81
|
+
key: "getLayerConfig",
|
|
82
|
+
value: function getLayerConfig() {
|
|
83
|
+
var config = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.getDefaultConfig()), (0, _get2.default)((0, _getPrototypeOf2.default)(CanvasLayer.prototype), "getLayerConfig", this).call(this));
|
|
84
|
+
if (config.zIndex < 3) {
|
|
85
|
+
config.zIndex = 3;
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
return config;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "render",
|
|
91
|
+
value: function render() {
|
|
92
|
+
var _this$layerModel;
|
|
93
|
+
(_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.renderCanvas();
|
|
84
94
|
return this;
|
|
85
95
|
}
|
|
86
96
|
}, {
|
|
87
|
-
key: "
|
|
88
|
-
value: function
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
canvas: {}
|
|
92
|
-
};
|
|
93
|
-
return defaultConfig[type];
|
|
97
|
+
key: "getCanvas",
|
|
98
|
+
value: function getCanvas() {
|
|
99
|
+
var _this$layerModel2;
|
|
100
|
+
return (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 ? void 0 : _this$layerModel2.canvas;
|
|
94
101
|
}
|
|
95
102
|
}, {
|
|
96
|
-
key: "
|
|
97
|
-
value: function
|
|
98
|
-
|
|
103
|
+
key: "show",
|
|
104
|
+
value: function show() {
|
|
105
|
+
var canvas = this.getCanvas();
|
|
106
|
+
if (canvas) {
|
|
107
|
+
canvas.style.display = 'unset';
|
|
108
|
+
}
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "hide",
|
|
113
|
+
value: function hide() {
|
|
114
|
+
var canvas = this.getCanvas();
|
|
115
|
+
if (canvas) {
|
|
116
|
+
canvas.style.display = 'none';
|
|
117
|
+
}
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "destroy",
|
|
122
|
+
value: function destroy() {
|
|
123
|
+
this.layerModel.removeCanvas();
|
|
124
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(CanvasLayer.prototype), "destroy", this).call(this);
|
|
99
125
|
}
|
|
100
126
|
}]);
|
|
101
127
|
return CanvasLayer;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.CanvasModel = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -17,122 +17,133 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
17
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
18
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
19
19
|
var _interface = require("../../core/interface");
|
|
20
|
+
var _constants = require("./constants");
|
|
20
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); }; }
|
|
21
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; } }
|
|
22
|
-
var
|
|
23
|
-
(0, _inherits2.default)(
|
|
24
|
-
var _super = _createSuper(
|
|
25
|
-
function
|
|
23
|
+
var CanvasModel = exports.CanvasModel = /*#__PURE__*/function (_BaseModel) {
|
|
24
|
+
(0, _inherits2.default)(CanvasModel, _BaseModel);
|
|
25
|
+
var _super = _createSuper(CanvasModel);
|
|
26
|
+
function CanvasModel() {
|
|
26
27
|
var _this;
|
|
27
|
-
(0, _classCallCheck2.default)(this,
|
|
28
|
+
(0, _classCallCheck2.default)(this, CanvasModel);
|
|
28
29
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
30
|
args[_key] = arguments[_key];
|
|
30
31
|
}
|
|
31
32
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
33
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
zIndex =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (_this.updateMode === _interface.CanvasUpdateType.ALWAYS && animateOption.enable) {
|
|
53
|
-
_this.renderCanvas();
|
|
33
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "canvas", null);
|
|
34
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initCanvas", function () {
|
|
35
|
+
var _this$mapService$getC, _this$mapService$getC2, _this$mapService, _this$mapService$getM, _this$mapService2;
|
|
36
|
+
var _this$layerConfig = _this.layerConfig,
|
|
37
|
+
zIndex = _this$layerConfig.zIndex,
|
|
38
|
+
getContext = _this$layerConfig.getContext;
|
|
39
|
+
var canvas = document.createElement('canvas');
|
|
40
|
+
var modelType = _this.layer.getModelType();
|
|
41
|
+
_this.canvas = canvas;
|
|
42
|
+
canvas.classList.add('l7-canvas-layer');
|
|
43
|
+
canvas.style.position = 'absolute';
|
|
44
|
+
canvas.style.top = '0';
|
|
45
|
+
canvas.style.left = '0';
|
|
46
|
+
canvas.style.zIndex = String(zIndex);
|
|
47
|
+
_this.resetCanvasSize();
|
|
48
|
+
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);
|
|
49
|
+
container === null || container === void 0 || container.appendChild(canvas);
|
|
50
|
+
_this.ctx = getContext ? getContext(canvas) : canvas.getContext(_constants.CanvasContextTypeMap[modelType]);
|
|
51
|
+
if (!_this.ctx) {
|
|
52
|
+
console.error('Failed to get rendering context for canvas');
|
|
54
53
|
}
|
|
54
|
+
_this.bindListeners();
|
|
55
55
|
});
|
|
56
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
57
|
-
_this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
_this.
|
|
61
|
-
_this.mapService.off('moveend', _this.renderCanvas);
|
|
62
|
-
});
|
|
63
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "bindListener", function () {
|
|
64
|
-
if (_this.updateMode === _interface.CanvasUpdateType.ALWAYS) {
|
|
65
|
-
_this.mapService.on('mapchange', _this.renderCanvas);
|
|
66
|
-
} else {
|
|
67
|
-
_this.mapService.on('zoomstart', _this.clearCanvas);
|
|
68
|
-
_this.mapService.on('zoomend', _this.renderCanvas);
|
|
69
|
-
_this.mapService.on('movestart', _this.clearCanvas);
|
|
70
|
-
_this.mapService.on('moveend', _this.renderCanvas);
|
|
71
|
-
}
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resetViewportSize", function () {
|
|
57
|
+
var _this$rendererService = _this.rendererService.getViewportSize(),
|
|
58
|
+
viewWidth = _this$rendererService.width,
|
|
59
|
+
viewHeight = _this$rendererService.height;
|
|
60
|
+
_this.viewportSize = [viewWidth, viewHeight];
|
|
72
61
|
});
|
|
73
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
h = _this$rendererService.height;
|
|
78
|
-
_this.ctx.clearRect(0, 0, w, h);
|
|
62
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resetCanvasSize", function () {
|
|
63
|
+
var canvas = _this.canvas;
|
|
64
|
+
if (!canvas) {
|
|
65
|
+
return;
|
|
79
66
|
}
|
|
67
|
+
_this.resetViewportSize();
|
|
68
|
+
var _this$mapService$getS = _this.mapService.getSize(),
|
|
69
|
+
_this$mapService$getS2 = (0, _slicedToArray2.default)(_this$mapService$getS, 2),
|
|
70
|
+
width = _this$mapService$getS2[0],
|
|
71
|
+
height = _this$mapService$getS2[1];
|
|
72
|
+
var _this$viewportSize = (0, _slicedToArray2.default)(_this.viewportSize, 2),
|
|
73
|
+
viewWidth = _this$viewportSize[0],
|
|
74
|
+
viewHeight = _this$viewportSize[1];
|
|
75
|
+
canvas.width = viewWidth;
|
|
76
|
+
canvas.height = viewHeight;
|
|
77
|
+
canvas.style.width = width + 'px';
|
|
78
|
+
canvas.style.height = height + 'px';
|
|
80
79
|
});
|
|
81
80
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderCanvas", function () {
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (_this.prevSize[0] !== viewWidth || _this.prevSize[1] !== viewHeight) {
|
|
86
|
-
_this.prevSize = [viewWidth, viewHeight];
|
|
87
|
-
var size = _this.mapService.getSize();
|
|
88
|
-
var _size = (0, _slicedToArray2.default)(size, 2),
|
|
89
|
-
width = _size[0],
|
|
90
|
-
height = _size[1];
|
|
91
|
-
_this.canvas.width = viewWidth;
|
|
92
|
-
_this.canvas.height = viewHeight;
|
|
93
|
-
_this.canvas.style.width = width + 'px';
|
|
94
|
-
_this.canvas.style.height = height + 'px';
|
|
81
|
+
var _ref;
|
|
82
|
+
if (!_this.canvas) {
|
|
83
|
+
_this.initCanvas();
|
|
95
84
|
}
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
85
|
+
var _this$layerConfig2 = _this.layerConfig,
|
|
86
|
+
draw = _this$layerConfig2.draw,
|
|
87
|
+
drawingOnCanvas = _this$layerConfig2.drawingOnCanvas;
|
|
88
|
+
var _this$viewportSize2 = (0, _slicedToArray2.default)(_this.viewportSize, 2),
|
|
89
|
+
width = _this$viewportSize2[0],
|
|
90
|
+
height = _this$viewportSize2[1];
|
|
91
|
+
var bounds = _this.mapService.getBounds();
|
|
92
|
+
(_ref = draw !== null && draw !== void 0 ? draw : drawingOnCanvas) === null || _ref === void 0 || _ref({
|
|
93
|
+
canvas: _this.canvas,
|
|
94
|
+
ctx: _this.ctx,
|
|
95
|
+
container: {
|
|
96
|
+
width: width,
|
|
97
|
+
height: height,
|
|
98
|
+
bounds: bounds
|
|
99
|
+
},
|
|
100
|
+
size: [width, height],
|
|
101
|
+
utils: {
|
|
102
|
+
lngLatToContainer: _this.lngLatToContainer
|
|
103
|
+
},
|
|
104
|
+
mapService: _this.mapService
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "removeCanvas", function () {
|
|
108
|
+
if (_this.canvas) {
|
|
109
|
+
var _this$canvas$parentEl;
|
|
110
|
+
(_this$canvas$parentEl = _this.canvas.parentElement) === null || _this$canvas$parentEl === void 0 || _this$canvas$parentEl.removeChild(_this.canvas);
|
|
111
|
+
_this.canvas = null;
|
|
105
112
|
}
|
|
113
|
+
_this.unbindListeners();
|
|
114
|
+
});
|
|
115
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMapResize", function () {
|
|
116
|
+
requestAnimationFrame(function () {
|
|
117
|
+
_this.resetCanvasSize();
|
|
118
|
+
_this.renderCanvas();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "lngLatToContainer", function (lngLat) {
|
|
122
|
+
var _this$mapService$lngL = _this.mapService.lngLatToContainer(lngLat),
|
|
123
|
+
x = _this$mapService$lngL.x,
|
|
124
|
+
y = _this$mapService$lngL.y;
|
|
125
|
+
return {
|
|
126
|
+
x: x * window.devicePixelRatio,
|
|
127
|
+
y: y * window.devicePixelRatio
|
|
128
|
+
};
|
|
106
129
|
});
|
|
107
130
|
return _this;
|
|
108
131
|
}
|
|
109
|
-
(0, _createClass2.default)(
|
|
110
|
-
key: "
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var _this$mapService$getC;
|
|
114
|
-
(_this$mapService$getC = this.mapService.getContainer()) === null || _this$mapService$getC === void 0 || _this$mapService$getC.removeChild(this.canvas);
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
this.canvas = null;
|
|
117
|
-
}
|
|
118
|
-
this.unBindListener();
|
|
132
|
+
(0, _createClass2.default)(CanvasModel, [{
|
|
133
|
+
key: "layerConfig",
|
|
134
|
+
get: function get() {
|
|
135
|
+
return this.layer.getLayerConfig();
|
|
119
136
|
}
|
|
120
137
|
}, {
|
|
121
138
|
key: "initModels",
|
|
122
139
|
value: function () {
|
|
123
140
|
var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
124
|
-
var _ref3, _ref3$update, update;
|
|
125
141
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
126
142
|
while (1) switch (_context.prev = _context.next) {
|
|
127
143
|
case 0:
|
|
128
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$update = _ref3.update, update = _ref3$update === void 0 ? _interface.CanvasUpdateType.ALWAYS : _ref3$update;
|
|
129
|
-
this.updateMode = update;
|
|
130
|
-
this.initCanvas();
|
|
131
144
|
this.renderCanvas();
|
|
132
|
-
this.bindListener();
|
|
133
|
-
this.mapService.getContainer();
|
|
134
145
|
return _context.abrupt("return", []);
|
|
135
|
-
case
|
|
146
|
+
case 2:
|
|
136
147
|
case "end":
|
|
137
148
|
return _context.stop();
|
|
138
149
|
}
|
|
@@ -144,58 +155,34 @@ var CanvaModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
144
155
|
return initModels;
|
|
145
156
|
}()
|
|
146
157
|
}, {
|
|
147
|
-
key: "
|
|
148
|
-
value: function
|
|
149
|
-
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.canvas = canvas;
|
|
162
|
-
canvas.width = viewWidth;
|
|
163
|
-
canvas.height = viewHeight;
|
|
164
|
-
canvas.style.pointerEvents = 'none';
|
|
165
|
-
canvas.style.width = width + 'px';
|
|
166
|
-
canvas.style.height = height + 'px';
|
|
167
|
-
canvas.style.position = 'absolute';
|
|
168
|
-
canvas.style.top = '0';
|
|
169
|
-
canvas.style.left = '0';
|
|
170
|
-
canvas.style.zIndex = zIndex + '';
|
|
171
|
-
(_this$mapService$getC2 = this.mapService.getContainer()) === null || _this$mapService$getC2 === void 0 || _this$mapService$getC2.appendChild(canvas);
|
|
172
|
-
var ctx = canvas.getContext('2d');
|
|
173
|
-
this.ctx = ctx;
|
|
158
|
+
key: "bindListeners",
|
|
159
|
+
value: function bindListeners() {
|
|
160
|
+
this.mapService.on('resize', this.onMapResize);
|
|
161
|
+
var _this$layerConfig3 = this.layerConfig,
|
|
162
|
+
trigger = _this$layerConfig3.trigger,
|
|
163
|
+
update = _this$layerConfig3.update;
|
|
164
|
+
if (update === _interface.CanvasUpdateType.ALWAYS || trigger === 'change') {
|
|
165
|
+
this.mapService.on('mapchange', this.renderCanvas);
|
|
166
|
+
} else {
|
|
167
|
+
this.mapService.on('zoomstart', this.removeCanvas);
|
|
168
|
+
this.mapService.on('zoomend', this.renderCanvas);
|
|
169
|
+
this.mapService.on('movestart', this.removeCanvas);
|
|
170
|
+
this.mapService.on('moveend', this.renderCanvas);
|
|
171
|
+
}
|
|
174
172
|
}
|
|
175
173
|
}, {
|
|
176
|
-
key: "
|
|
177
|
-
value: function () {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return _context2.stop();
|
|
186
|
-
}
|
|
187
|
-
}, _callee2, this);
|
|
188
|
-
}));
|
|
189
|
-
function buildModels() {
|
|
190
|
-
return _buildModels.apply(this, arguments);
|
|
191
|
-
}
|
|
192
|
-
return buildModels;
|
|
193
|
-
}()
|
|
174
|
+
key: "unbindListeners",
|
|
175
|
+
value: function unbindListeners() {
|
|
176
|
+
this.mapService.off('resize', this.onMapResize);
|
|
177
|
+
this.mapService.off('mapchange', this.renderCanvas);
|
|
178
|
+
this.mapService.off('zoomstart', this.removeCanvas);
|
|
179
|
+
this.mapService.off('zoomend', this.renderCanvas);
|
|
180
|
+
this.mapService.off('movestart', this.removeCanvas);
|
|
181
|
+
this.mapService.off('moveend', this.renderCanvas);
|
|
182
|
+
}
|
|
194
183
|
}, {
|
|
195
184
|
key: "registerBuiltinAttributes",
|
|
196
|
-
value: function registerBuiltinAttributes() {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
185
|
+
value: function registerBuiltinAttributes() {}
|
|
199
186
|
}]);
|
|
200
|
-
return
|
|
187
|
+
return CanvasModel;
|
|
201
188
|
}(_BaseModel2.default);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CanvasContextTypeMap = void 0;
|
|
7
|
+
var CanvasContextTypeMap = exports.CanvasContextTypeMap = {
|
|
8
|
+
canvas2d: '2d',
|
|
9
|
+
webgl: 'webgl',
|
|
10
|
+
webgl2: 'webgl2',
|
|
11
|
+
webgpu: 'webgpu'
|
|
12
|
+
};
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
var _canvas = require("./canvas");
|
|
7
|
+
Object.keys(_canvas).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _canvas[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _canvas[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _constants = require("./constants");
|
|
18
|
+
Object.keys(_constants).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _constants[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|