@antv/l7-layers 2.9.15 → 2.9.16
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/LICENSE.md +1 -1
- package/es/core/BaseLayer.d.ts +4 -2
- package/es/core/BaseLayer.js +47 -21
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/BaseModel.d.ts +2 -1
- package/es/core/BaseModel.js +3 -0
- package/es/core/BaseModel.js.map +1 -1
- package/es/core/interface.d.ts +14 -1
- package/es/core/interface.js.map +1 -1
- package/es/image/models/image.js.map +1 -1
- package/es/line/index.d.ts +1 -1
- package/es/line/index.js +13 -1
- package/es/line/index.js.map +1 -1
- package/es/line/models/earthArc_3d.d.ts +17 -0
- package/es/line/models/earthArc_3d.js +311 -0
- package/es/line/models/earthArc_3d.js.map +1 -0
- package/es/line/models/half.d.ts +18 -0
- package/es/line/models/half.js +244 -0
- package/es/line/models/half.js.map +1 -0
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +9 -1
- package/es/line/models/index.js.map +1 -1
- package/es/line/models/tile.d.ts +20 -0
- package/es/line/models/tile.js +327 -0
- package/es/line/models/tile.js.map +1 -0
- package/es/plugins/DataMappingPlugin.js +1 -1
- package/es/plugins/DataMappingPlugin.js.map +1 -1
- package/es/plugins/DataSourcePlugin.js +7 -6
- package/es/plugins/DataSourcePlugin.js.map +1 -1
- package/es/plugins/FeatureScalePlugin.js +35 -9
- package/es/plugins/FeatureScalePlugin.js.map +1 -1
- package/es/plugins/ShaderUniformPlugin.js +3 -1
- package/es/plugins/ShaderUniformPlugin.js.map +1 -1
- package/es/point/index.d.ts +1 -1
- package/es/point/index.js +10 -2
- package/es/point/index.js.map +1 -1
- package/es/point/models/earthExtrude.d.ts +24 -0
- package/es/point/models/earthExtrude.js +259 -0
- package/es/point/models/earthExtrude.js.map +1 -0
- package/es/point/models/earthFill.d.ts +20 -0
- package/es/point/models/earthFill.js +255 -0
- package/es/point/models/earthFill.js.map +1 -0
- package/es/point/models/extrude.d.ts +0 -1
- package/es/point/models/extrude.js +2 -10
- package/es/point/models/extrude.js.map +1 -1
- package/es/point/models/fill.d.ts +8 -1
- package/es/point/models/fill.js +55 -75
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +9 -1
- package/es/point/models/index.js.map +1 -1
- package/es/point/models/radar.js +2 -6
- package/es/point/models/radar.js.map +1 -1
- package/es/point/models/tile.d.ts +31 -0
- package/es/point/models/tile.js +291 -0
- package/es/point/models/tile.js.map +1 -0
- package/es/polygon/index.js +6 -0
- package/es/polygon/index.js.map +1 -1
- package/es/polygon/models/index.d.ts +1 -1
- package/es/polygon/models/index.js +5 -1
- package/es/polygon/models/index.js.map +1 -1
- package/es/polygon/models/tile.d.ts +16 -0
- package/es/polygon/models/tile.js +137 -0
- package/es/polygon/models/tile.js.map +1 -0
- package/es/raster/index.d.ts +2 -2
- package/es/raster/index.js +4 -4
- package/es/raster/index.js.map +1 -1
- package/es/raster/models/index.js +1 -1
- package/es/raster/models/index.js.map +1 -1
- package/es/raster/models/raster.d.ts +2 -0
- package/es/raster/models/raster.js +24 -12
- package/es/raster/models/raster.js.map +1 -1
- package/es/tile/interface.d.ts +28 -0
- package/es/tile/interface.js +2 -0
- package/es/tile/interface.js.map +1 -0
- package/es/tile/manager/tileConfigManager.d.ts +17 -0
- package/es/tile/manager/tileConfigManager.js +123 -0
- package/es/tile/manager/tileConfigManager.js.map +1 -0
- package/es/tile/manager/tileLayerManager.d.ts +35 -0
- package/es/tile/manager/tileLayerManager.js +297 -0
- package/es/tile/manager/tileLayerManager.js.map +1 -0
- package/es/tile/manager/tilePickerManager.d.ts +21 -0
- package/es/tile/manager/tilePickerManager.js +189 -0
- package/es/tile/manager/tilePickerManager.js.map +1 -0
- package/es/tile/models/tileModel.d.ts +8 -0
- package/es/tile/models/tileModel.js +61 -0
- package/es/tile/models/tileModel.js.map +1 -0
- package/es/tile/tileFactory/base.d.ts +44 -0
- package/es/tile/tileFactory/base.js +423 -0
- package/es/tile/tileFactory/base.js.map +1 -0
- package/es/tile/tileFactory/index.d.ts +5 -0
- package/es/tile/tileFactory/index.js +30 -0
- package/es/tile/tileFactory/index.js.map +1 -0
- package/es/tile/tileFactory/line.d.ts +12 -0
- package/es/tile/tileFactory/line.js +65 -0
- package/es/tile/tileFactory/line.js.map +1 -0
- package/es/tile/tileFactory/point.d.ts +12 -0
- package/es/tile/tileFactory/point.js +65 -0
- package/es/tile/tileFactory/point.js.map +1 -0
- package/es/tile/tileFactory/polygon.d.ts +12 -0
- package/es/tile/tileFactory/polygon.js +65 -0
- package/es/tile/tileFactory/polygon.js.map +1 -0
- package/es/tile/tileFactory/raster.d.ts +12 -0
- package/es/tile/tileFactory/raster.js +61 -0
- package/es/tile/tileFactory/raster.js.map +1 -0
- package/es/tile/tileFactory/rasterData.d.ts +12 -0
- package/es/tile/tileFactory/rasterData.js +86 -0
- package/es/tile/tileFactory/rasterData.js.map +1 -0
- package/es/tile/tileFactory/rasterDataLayer.d.ts +19 -0
- package/es/{core/LayerGroup.js → tile/tileFactory/rasterDataLayer.js} +39 -32
- package/es/tile/tileFactory/rasterDataLayer.js.map +1 -0
- package/es/tile/tileFactory/vectorLayer.d.ts +27 -0
- package/es/tile/tileFactory/vectorLayer.js +131 -0
- package/es/tile/tileFactory/vectorLayer.js.map +1 -0
- package/es/tile/tileLayer/baseTileLayer.d.ts +47 -0
- package/es/tile/tileLayer/baseTileLayer.js +409 -0
- package/es/tile/tileLayer/baseTileLayer.js.map +1 -0
- package/es/tile/tmsTileLayer.d.ts +7 -0
- package/es/tile/tmsTileLayer.js +100 -0
- package/es/tile/tmsTileLayer.js.map +1 -0
- package/es/tile/utils.d.ts +11 -0
- package/es/tile/utils.js +125 -0
- package/es/tile/utils.js.map +1 -0
- package/lib/core/BaseLayer.js +45 -20
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/BaseModel.js +2 -0
- package/lib/core/BaseModel.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/image/models/image.js.map +1 -1
- package/lib/line/index.js +13 -1
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/earthArc_3d.js +328 -0
- package/lib/line/models/earthArc_3d.js.map +1 -0
- package/lib/line/models/half.js +260 -0
- package/lib/line/models/half.js.map +1 -0
- package/lib/line/models/index.js +13 -1
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/tile.js +342 -0
- package/lib/line/models/tile.js.map +1 -0
- package/lib/plugins/DataMappingPlugin.js +1 -1
- package/lib/plugins/DataMappingPlugin.js.map +1 -1
- package/lib/plugins/DataSourcePlugin.js +7 -6
- package/lib/plugins/DataSourcePlugin.js.map +1 -1
- package/lib/plugins/FeatureScalePlugin.js +35 -9
- package/lib/plugins/FeatureScalePlugin.js.map +1 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -1
- package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
- package/lib/point/index.js +10 -2
- package/lib/point/index.js.map +1 -1
- package/lib/point/models/earthExtrude.js +277 -0
- package/lib/point/models/earthExtrude.js.map +1 -0
- package/lib/point/models/earthFill.js +291 -0
- package/lib/point/models/earthFill.js.map +1 -0
- package/lib/point/models/extrude.js +2 -11
- package/lib/point/models/extrude.js.map +1 -1
- package/lib/point/models/fill.js +51 -93
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/index.js +13 -1
- package/lib/point/models/index.js.map +1 -1
- package/lib/point/models/radar.js +1 -5
- package/lib/point/models/radar.js.map +1 -1
- package/lib/point/models/tile.js +308 -0
- package/lib/point/models/tile.js.map +1 -0
- package/lib/polygon/index.js +6 -0
- package/lib/polygon/index.js.map +1 -1
- package/lib/polygon/models/index.js +7 -1
- package/lib/polygon/models/index.js.map +1 -1
- package/lib/polygon/models/tile.js +152 -0
- package/lib/polygon/models/tile.js.map +1 -0
- package/lib/raster/index.js +4 -4
- package/lib/raster/index.js.map +1 -1
- package/lib/raster/models/index.js +2 -2
- package/lib/raster/models/index.js.map +1 -1
- package/lib/raster/models/raster.js +24 -12
- package/lib/raster/models/raster.js.map +1 -1
- package/lib/tile/interface.js +2 -0
- package/lib/tile/interface.js.map +1 -0
- package/lib/tile/manager/tileConfigManager.js +134 -0
- package/lib/tile/manager/tileConfigManager.js.map +1 -0
- package/lib/tile/manager/tileLayerManager.js +305 -0
- package/lib/tile/manager/tileLayerManager.js.map +1 -0
- package/lib/tile/manager/tilePickerManager.js +195 -0
- package/lib/tile/manager/tilePickerManager.js.map +1 -0
- package/lib/tile/models/tileModel.js +73 -0
- package/lib/tile/models/tileModel.js.map +1 -0
- package/lib/tile/tileFactory/base.js +436 -0
- package/lib/tile/tileFactory/base.js.map +1 -0
- package/lib/tile/tileFactory/index.js +60 -0
- package/lib/tile/tileFactory/index.js.map +1 -0
- package/lib/tile/tileFactory/line.js +76 -0
- package/lib/tile/tileFactory/line.js.map +1 -0
- package/lib/tile/tileFactory/point.js +76 -0
- package/lib/tile/tileFactory/point.js.map +1 -0
- package/lib/tile/tileFactory/polygon.js +76 -0
- package/lib/tile/tileFactory/polygon.js.map +1 -0
- package/lib/tile/tileFactory/raster.js +74 -0
- package/lib/tile/tileFactory/raster.js.map +1 -0
- package/lib/tile/tileFactory/rasterData.js +99 -0
- package/lib/tile/tileFactory/rasterData.js.map +1 -0
- package/lib/{core/LayerGroup.js → tile/tileFactory/rasterDataLayer.js} +40 -32
- package/lib/tile/tileFactory/rasterDataLayer.js.map +1 -0
- package/lib/tile/tileFactory/vectorLayer.js +145 -0
- package/lib/tile/tileFactory/vectorLayer.js.map +1 -0
- package/lib/tile/tileLayer/baseTileLayer.js +407 -0
- package/lib/tile/tileLayer/baseTileLayer.js.map +1 -0
- package/lib/tile/tmsTileLayer.js +116 -0
- package/lib/tile/tmsTileLayer.js.map +1 -0
- package/lib/tile/utils.js +147 -0
- package/lib/tile/utils.js.map +1 -0
- package/package.json +8 -6
- package/es/core/LayerGroup.d.ts +0 -9
- package/es/core/LayerGroup.js.map +0 -1
- package/es/raster/models/raste-tile.d.ts +0 -23
- package/es/raster/models/raste-tile.js +0 -285
- package/es/raster/models/raste-tile.js.map +0 -1
- package/lib/core/LayerGroup.js.map +0 -1
- package/lib/raster/models/raste-tile.js +0 -294
- package/lib/raster/models/raste-tile.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getContainerSize = getContainerSize;
|
|
9
|
+
exports.getLayerShape = getLayerShape;
|
|
10
|
+
exports.getMaskValue = getMaskValue;
|
|
11
|
+
exports.readPixel = readPixel;
|
|
12
|
+
exports.readRasterValue = readRasterValue;
|
|
13
|
+
exports.registerLayers = registerLayers;
|
|
14
|
+
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
|
|
17
|
+
var _l7Core = require("@antv/l7-core");
|
|
18
|
+
|
|
19
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
20
|
+
|
|
21
|
+
function registerLayers(parentLayer, layers) {
|
|
22
|
+
layers.map(function (layer) {
|
|
23
|
+
var container = (0, _l7Core.createLayerContainer)(parentLayer.sceneContainer);
|
|
24
|
+
layer.setContainer(container, parentLayer.sceneContainer);
|
|
25
|
+
layer.init();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getLayerShape(layerType, layer) {
|
|
30
|
+
var _layerShape$scale;
|
|
31
|
+
|
|
32
|
+
var layerShape = layer.getAttribute('shape');
|
|
33
|
+
|
|
34
|
+
if (layerShape && (_layerShape$scale = layerShape.scale) !== null && _layerShape$scale !== void 0 && _layerShape$scale.field) {
|
|
35
|
+
var _layerShape$scale2;
|
|
36
|
+
|
|
37
|
+
if (((_layerShape$scale2 = layerShape.scale) === null || _layerShape$scale2 === void 0 ? void 0 : _layerShape$scale2.values) === 'text') {
|
|
38
|
+
return [layerShape.scale.field, layerShape.scale.values];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return layerShape.scale.field;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
switch (layerType) {
|
|
45
|
+
case 'PolygonLayer':
|
|
46
|
+
return 'fill';
|
|
47
|
+
|
|
48
|
+
case 'LineLayer':
|
|
49
|
+
return 'tileline';
|
|
50
|
+
|
|
51
|
+
case 'PointLayer':
|
|
52
|
+
return 'circle';
|
|
53
|
+
|
|
54
|
+
case 'RasterLayer':
|
|
55
|
+
return 'image';
|
|
56
|
+
|
|
57
|
+
default:
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getMaskValue(layerType, mask) {
|
|
63
|
+
switch (layerType) {
|
|
64
|
+
case 'PolygonLayer':
|
|
65
|
+
return true;
|
|
66
|
+
|
|
67
|
+
case 'LineLayer':
|
|
68
|
+
return true;
|
|
69
|
+
|
|
70
|
+
case 'PointLayer':
|
|
71
|
+
return false;
|
|
72
|
+
|
|
73
|
+
case 'RasterLayer':
|
|
74
|
+
return mask;
|
|
75
|
+
|
|
76
|
+
default:
|
|
77
|
+
return mask;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getContainerSize(container) {
|
|
82
|
+
if (!!container.getContext) {
|
|
83
|
+
return {
|
|
84
|
+
width: container.width / _l7Utils.DOM.DPR,
|
|
85
|
+
height: container.height / _l7Utils.DOM.DPR
|
|
86
|
+
};
|
|
87
|
+
} else {
|
|
88
|
+
return container.getBoundingClientRect();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function readRasterValue(tile, mapService, x, y) {
|
|
93
|
+
var _tile$bboxPolygon, _tile$data, _tile$data2, _tile$data3;
|
|
94
|
+
|
|
95
|
+
var bbox = (tile === null || tile === void 0 ? void 0 : (_tile$bboxPolygon = tile.bboxPolygon) === null || _tile$bboxPolygon === void 0 ? void 0 : _tile$bboxPolygon.bbox) || [0, 0, 10, -10];
|
|
96
|
+
|
|
97
|
+
var _bbox = (0, _slicedToArray2.default)(bbox, 4),
|
|
98
|
+
_bbox$ = _bbox[0],
|
|
99
|
+
minLng = _bbox$ === void 0 ? 0 : _bbox$,
|
|
100
|
+
_bbox$2 = _bbox[1],
|
|
101
|
+
minLat = _bbox$2 === void 0 ? 0 : _bbox$2,
|
|
102
|
+
_bbox$3 = _bbox[2],
|
|
103
|
+
maxLng = _bbox$3 === void 0 ? 10 : _bbox$3,
|
|
104
|
+
_bbox$4 = _bbox[3],
|
|
105
|
+
maxLat = _bbox$4 === void 0 ? -10 : _bbox$4;
|
|
106
|
+
|
|
107
|
+
var tileXY = mapService.lngLatToContainer([minLng, minLat]);
|
|
108
|
+
var tileMaxXY = mapService.lngLatToContainer([maxLng, maxLat]);
|
|
109
|
+
var tilePixelWidth = tileMaxXY.x - tileXY.x;
|
|
110
|
+
var tilePixelHeight = tileXY.y - tileMaxXY.y;
|
|
111
|
+
var pos = [(x - tileXY.x) / tilePixelWidth, (y - tileMaxXY.y) / tilePixelHeight];
|
|
112
|
+
var tileWidth = (tile === null || tile === void 0 ? void 0 : (_tile$data = tile.data) === null || _tile$data === void 0 ? void 0 : _tile$data.width) || 1;
|
|
113
|
+
var tileHeight = (tile === null || tile === void 0 ? void 0 : (_tile$data2 = tile.data) === null || _tile$data2 === void 0 ? void 0 : _tile$data2.height) || 1;
|
|
114
|
+
var indexX = Math.floor(pos[0] * tileWidth);
|
|
115
|
+
var indexY = Math.floor(pos[1] * tileHeight);
|
|
116
|
+
var index = Math.max(0, indexY - 1) * tileWidth + indexX;
|
|
117
|
+
var data = tile === null || tile === void 0 ? void 0 : (_tile$data3 = tile.data) === null || _tile$data3 === void 0 ? void 0 : _tile$data3.data[index];
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function readPixel(x, y, rendererService) {
|
|
122
|
+
var readPixels = rendererService.readPixels,
|
|
123
|
+
getContainer = rendererService.getContainer;
|
|
124
|
+
var xInDevicePixel = x * _l7Utils.DOM.DPR;
|
|
125
|
+
var yInDevicePixel = y * _l7Utils.DOM.DPR;
|
|
126
|
+
|
|
127
|
+
var _getContainerSize = getContainerSize(getContainer()),
|
|
128
|
+
width = _getContainerSize.width,
|
|
129
|
+
height = _getContainerSize.height;
|
|
130
|
+
|
|
131
|
+
width *= _l7Utils.DOM.DPR;
|
|
132
|
+
height *= _l7Utils.DOM.DPR;
|
|
133
|
+
|
|
134
|
+
if (xInDevicePixel > width - 1 * _l7Utils.DOM.DPR || xInDevicePixel < 0 || yInDevicePixel > height - 1 * _l7Utils.DOM.DPR || yInDevicePixel < 0) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var pickedColors = readPixels({
|
|
139
|
+
x: Math.floor(xInDevicePixel),
|
|
140
|
+
y: Math.floor(height - (y + 1) * _l7Utils.DOM.DPR),
|
|
141
|
+
width: 1,
|
|
142
|
+
height: 1,
|
|
143
|
+
data: new Uint8Array(1 * 1 * 4)
|
|
144
|
+
});
|
|
145
|
+
return pickedColors;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tile/utils.ts"],"names":["registerLayers","parentLayer","layers","map","layer","container","sceneContainer","setContainer","init","getLayerShape","layerType","layerShape","getAttribute","scale","field","values","getMaskValue","mask","getContainerSize","getContext","width","DOM","DPR","height","getBoundingClientRect","readRasterValue","tile","mapService","x","y","bbox","bboxPolygon","minLng","minLat","maxLng","maxLat","tileXY","lngLatToContainer","tileMaxXY","tilePixelWidth","tilePixelHeight","pos","tileWidth","data","tileHeight","indexX","Math","floor","indexY","index","max","readPixel","rendererService","readPixels","getContainer","xInDevicePixel","yInDevicePixel","pickedColors","Uint8Array"],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AAK,GAAG,IAAIC,aAAIC,GAAjC,IACAiC,cAAc,GAAG,CADjB,IAEAC,cAAc,GAAGjC,MAAM,GAAG,IAAIF,aAAIC,GAFlC,IAGAkC,cAAc,GAAG,CAJnB,EAKE;AACA,WAAO,KAAP;AACD;;AAED,MAAMC,YAAY,GAAGJ,UAAU,CAAC;AAC9BzB,IAAAA,CAAC,EAAEkB,IAAI,CAACC,KAAL,CAAWQ,cAAX,CAD2B;AAG9B1B,IAAAA,CAAC,EAAEiB,IAAI,CAACC,KAAL,CAAWxB,MAAM,GAAG,CAACM,CAAC,GAAG,CAAL,IAAUR,aAAIC,GAAlC,CAH2B;AAI9BF,IAAAA,KAAK,EAAE,CAJuB;AAK9BG,IAAAA,MAAM,EAAE,CALsB;AAM9BoB,IAAAA,IAAI,EAAE,IAAIe,UAAJ,CAAe,IAAI,CAAJ,GAAQ,CAAvB;AANwB,GAAD,CAA/B;AAQA,SAAOD,YAAP;AACD","sourcesContent":["import {\n createLayerContainer,\n ILayer,\n IMapService,\n IRendererService,\n} from '@antv/l7-core';\nimport { DOM, Tile } from '@antv/l7-utils';\nimport { Container } from 'inversify';\nexport function registerLayers(parentLayer: ILayer, layers: ILayer[]) {\n layers.map((layer) => {\n const container = createLayerContainer(\n parentLayer.sceneContainer as Container,\n );\n layer.setContainer(container, parentLayer.sceneContainer as Container);\n layer.init();\n });\n}\n\nexport function getLayerShape(layerType: string, layer: ILayer) {\n const layerShape = layer.getAttribute('shape');\n if (layerShape && layerShape.scale?.field) {\n if (layerShape.scale?.values === 'text') {\n return [layerShape.scale.field, layerShape.scale.values] as string[];\n }\n return layerShape.scale.field as string;\n }\n switch (layerType) {\n case 'PolygonLayer':\n return 'fill';\n case 'LineLayer':\n return 'tileline';\n case 'PointLayer':\n return 'circle';\n case 'RasterLayer':\n return 'image';\n default:\n return '';\n }\n}\n\nexport function getMaskValue(layerType: string, mask: boolean) {\n switch (layerType) {\n case 'PolygonLayer':\n return true;\n case 'LineLayer':\n return true;\n case 'PointLayer':\n return false;\n case 'RasterLayer':\n return mask;\n default:\n return mask;\n }\n}\n\nexport function getContainerSize(container: HTMLCanvasElement | HTMLElement) {\n if (!!(container as HTMLCanvasElement).getContext) {\n return {\n width: (container as HTMLCanvasElement).width / DOM.DPR,\n height: (container as HTMLCanvasElement).height / DOM.DPR,\n };\n } else {\n return container.getBoundingClientRect();\n }\n}\n\nexport function readRasterValue(\n tile: Tile,\n mapService: IMapService,\n x: number,\n y: number,\n) {\n const bbox = tile?.bboxPolygon?.bbox || [0, 0, 10, -10];\n\n const [minLng = 0, minLat = 0, maxLng = 10, maxLat = -10] = bbox;\n\n const tileXY = mapService.lngLatToContainer([minLng, minLat]);\n const tileMaxXY = mapService.lngLatToContainer([maxLng, maxLat]);\n\n const tilePixelWidth = tileMaxXY.x - tileXY.x;\n const tilePixelHeight = tileXY.y - tileMaxXY.y;\n const pos = [\n (x - tileXY.x) / tilePixelWidth, // x\n (y - tileMaxXY.y) / tilePixelHeight, // y\n ];\n\n const tileWidth = tile?.data?.width || 1;\n const tileHeight = tile?.data?.height || 1;\n\n const indexX = Math.floor(pos[0] * tileWidth);\n const indexY = Math.floor(pos[1] * tileHeight);\n const index = Math.max(0, indexY - 1) * tileWidth + indexX;\n\n const data = tile?.data?.data[index];\n\n return data;\n}\n\nexport function readPixel(\n x: number,\n y: number,\n rendererService: IRendererService,\n) {\n const { readPixels, getContainer } = rendererService;\n const xInDevicePixel = x * DOM.DPR;\n const yInDevicePixel = y * DOM.DPR;\n let { width, height } = getContainerSize(\n getContainer() as HTMLCanvasElement | HTMLElement,\n );\n width *= DOM.DPR;\n height *= DOM.DPR;\n if (\n xInDevicePixel > width - 1 * DOM.DPR ||\n xInDevicePixel < 0 ||\n yInDevicePixel > height - 1 * DOM.DPR ||\n yInDevicePixel < 0\n ) {\n return false;\n }\n\n const pickedColors = readPixels({\n x: Math.floor(xInDevicePixel),\n // 视口坐标系原点在左上,而 WebGL 在左下,需要翻转 Y 轴\n y: Math.floor(height - (y + 1) * DOM.DPR),\n width: 1,\n height: 1,\n data: new Uint8Array(1 * 1 * 4),\n });\n return pickedColors;\n}\n"],"file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.16",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -25,12 +25,14 @@
|
|
|
25
25
|
"author": "xiaoiver",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@antv/l7-core": "2.9.
|
|
29
|
-
"@antv/l7-source": "2.9.
|
|
30
|
-
"@antv/l7-utils": "2.9.
|
|
28
|
+
"@antv/l7-core": "2.9.16",
|
|
29
|
+
"@antv/l7-source": "2.9.16",
|
|
30
|
+
"@antv/l7-utils": "2.9.16",
|
|
31
31
|
"@babel/runtime": "^7.7.7",
|
|
32
32
|
"@mapbox/martini": "^0.2.0",
|
|
33
|
+
"@turf/helpers": "^6.1.4",
|
|
33
34
|
"@turf/meta": "^6.0.2",
|
|
35
|
+
"@turf/union": "^6.5.0",
|
|
34
36
|
"d3-array": "1",
|
|
35
37
|
"d3-color": "^1.4.0",
|
|
36
38
|
"d3-interpolate": "1.4.0",
|
|
@@ -49,13 +51,13 @@
|
|
|
49
51
|
"devDependencies": {
|
|
50
52
|
"@types/d3-array": "^2.0.0",
|
|
51
53
|
"@types/d3-color": "^1.2.2",
|
|
52
|
-
"@types/d3-interpolate": "1.
|
|
54
|
+
"@types/d3-interpolate": "1.1.6",
|
|
53
55
|
"@types/d3-scale": "^2.1.1",
|
|
54
56
|
"@types/earcut": "^2.1.0",
|
|
55
57
|
"@types/gl-matrix": "^2.4.5",
|
|
56
58
|
"@types/lodash": "^4.14.138"
|
|
57
59
|
},
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "7a4758195bb4d33cfb40e50536768e097b359022",
|
|
59
61
|
"publishConfig": {
|
|
60
62
|
"access": "public"
|
|
61
63
|
}
|
package/es/core/LayerGroup.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ILayer, ILayerGroup } from '@antv/l7-core';
|
|
2
|
-
import BaseLayer from './BaseLayer';
|
|
3
|
-
export default class LayerGroup<ChildLayerStyleOptions = {}> extends BaseLayer<ChildLayerStyleOptions> implements ILayerGroup {
|
|
4
|
-
isLayerGroup: boolean;
|
|
5
|
-
addChild(layer: ILayer): void;
|
|
6
|
-
removeChild(layer: ILayer): void;
|
|
7
|
-
clearChild(): void;
|
|
8
|
-
hasChild(layer: ILayer): boolean;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/LayerGroup.ts"],"names":["BaseLayer","LayerGroup","layer","layerChildren","push","layerIndex","indexOf","splice","destroy","forEach","includes"],"mappings":";;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,aAAtB;;IAIqBC,U;;;;;;;;;;;;;;;;mEAGY,I;;;;;;;WAE/B,kBAAgBC,KAAhB,EAA+B;AAC7B,WAAKC,aAAL,CAAmBC,IAAnB,CAAwBF,KAAxB;AACD;;;WAED,qBAAmBA,KAAnB,EAAkC;AAChC,UAAMG,UAAU,GAAG,KAAKF,aAAL,CAAmBG,OAAnB,CAA2BJ,KAA3B,CAAnB;;AACA,UAAIG,UAAU,GAAG,CAAC,CAAlB,EAAqB;AACnB,aAAKF,aAAL,CAAmBI,MAAnB,CAA0BF,UAA1B,EAAsC,CAAtC;AACD;;AACDH,MAAAA,KAAK,CAACM,OAAN;AACD;;;WAED,sBAAoB;AAClB,WAAKL,aAAL,CAAmBM,OAAnB,CAA2B,UAACP,KAAD,EAAgB;AACzCA,QAAAA,KAAK,CAACM,OAAN;AACD,OAFD;AAIA,WAAKL,aAAL,GAAqB,EAArB;AACD;;;WAED,kBAAgBD,KAAhB,EAA+B;AAC7B,aAAO,KAAKC,aAAL,CAAmBO,QAAnB,CAA4BR,KAA5B,CAAP;AACD;;;;EA1BOF,S;;SADWC,U","sourcesContent":["import { ILayer, ILayerGroup } from '@antv/l7-core';\nimport BaseLayer from './BaseLayer';\n\n// 定义 LayerGroup 继承 Baselayer\n\nexport default class LayerGroup<ChildLayerStyleOptions = {}>\n extends BaseLayer<ChildLayerStyleOptions>\n implements ILayerGroup {\n public isLayerGroup: boolean = true;\n\n public addChild(layer: ILayer) {\n this.layerChildren.push(layer);\n }\n\n public removeChild(layer: ILayer) {\n const layerIndex = this.layerChildren.indexOf(layer);\n if (layerIndex > -1) {\n this.layerChildren.splice(layerIndex, 1);\n }\n layer.destroy();\n }\n\n public clearChild() {\n this.layerChildren.forEach((layer: any) => {\n layer.destroy();\n });\n\n this.layerChildren = [];\n }\n\n public hasChild(layer: ILayer) {\n return this.layerChildren.includes(layer);\n }\n}\n"],"file":"LayerGroup.js"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { IModelUniform } from '@antv/l7-core';
|
|
2
|
-
import { TilesetManager } from '@antv/l7-utils';
|
|
3
|
-
import BaseModel from '../../core/BaseModel';
|
|
4
|
-
export default class RasterTileModel extends BaseModel {
|
|
5
|
-
initedTileset: boolean;
|
|
6
|
-
tilesetManager: TilesetManager | undefined;
|
|
7
|
-
showGrid: boolean;
|
|
8
|
-
private subGridLayer;
|
|
9
|
-
private subTextLayer;
|
|
10
|
-
private lastViewStates;
|
|
11
|
-
private timer;
|
|
12
|
-
getUninforms(): IModelUniform;
|
|
13
|
-
initModels(): never[];
|
|
14
|
-
buildModels(): never[];
|
|
15
|
-
clearModels(): void;
|
|
16
|
-
renderSubGridLayer(): void;
|
|
17
|
-
protected registerBuiltinAttributes(): void;
|
|
18
|
-
private bindTilesetEvent;
|
|
19
|
-
private creatSubLayer;
|
|
20
|
-
private renderSubLayers;
|
|
21
|
-
private destroySubLayer;
|
|
22
|
-
private getCurrentView;
|
|
23
|
-
}
|
|
@@ -1,285 +0,0 @@
|
|
|
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 { createLayerContainer } from '@antv/l7-core';
|
|
14
|
-
import BaseModel from '../../core/BaseModel';
|
|
15
|
-
import ImageLayer from '../../image';
|
|
16
|
-
import LineLayer from '../../line';
|
|
17
|
-
import PointLayer from '../../point';
|
|
18
|
-
|
|
19
|
-
var RasterTileModel = function (_BaseModel) {
|
|
20
|
-
_inherits(RasterTileModel, _BaseModel);
|
|
21
|
-
|
|
22
|
-
var _super = _createSuper(RasterTileModel);
|
|
23
|
-
|
|
24
|
-
function RasterTileModel() {
|
|
25
|
-
var _this;
|
|
26
|
-
|
|
27
|
-
_classCallCheck(this, RasterTileModel);
|
|
28
|
-
|
|
29
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
-
args[_key] = arguments[_key];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
|
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "initedTileset", false);
|
|
36
|
-
|
|
37
|
-
_defineProperty(_assertThisInitialized(_this), "tilesetManager", void 0);
|
|
38
|
-
|
|
39
|
-
_defineProperty(_assertThisInitialized(_this), "showGrid", false);
|
|
40
|
-
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "subGridLayer", void 0);
|
|
42
|
-
|
|
43
|
-
_defineProperty(_assertThisInitialized(_this), "subTextLayer", void 0);
|
|
44
|
-
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "lastViewStates", void 0);
|
|
46
|
-
|
|
47
|
-
_defineProperty(_assertThisInitialized(_this), "timer", void 0);
|
|
48
|
-
|
|
49
|
-
_defineProperty(_assertThisInitialized(_this), "renderSubLayers", function () {
|
|
50
|
-
if (!_this.tilesetManager) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var rasteTileLayer = _this.layer;
|
|
55
|
-
|
|
56
|
-
_this.tilesetManager.tiles.filter(function (tile) {
|
|
57
|
-
return tile.isLoaded;
|
|
58
|
-
}).map(function (tile) {
|
|
59
|
-
if (!tile.layer) {
|
|
60
|
-
tile.layer = _this.creatSubLayer(tile);
|
|
61
|
-
rasteTileLayer.addChild(tile.layer);
|
|
62
|
-
} else {
|
|
63
|
-
tile.layer.updateLayerConfig({
|
|
64
|
-
visible: tile.isVisible
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return tile.layer;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (_this.showGrid) {
|
|
72
|
-
if (!rasteTileLayer.hasChild(_this.subGridLayer)) {
|
|
73
|
-
rasteTileLayer.addChild(_this.subGridLayer);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!rasteTileLayer.hasChild(_this.subTextLayer)) {
|
|
77
|
-
rasteTileLayer.addChild(_this.subTextLayer);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_this.layerService.renderLayers();
|
|
82
|
-
|
|
83
|
-
if (_this.tilesetManager.isLoaded) {
|
|
84
|
-
rasteTileLayer.emit('tiles-loaded', _this.tilesetManager.currentTiles);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return _this;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_createClass(RasterTileModel, [{
|
|
92
|
-
key: "getUninforms",
|
|
93
|
-
value: function getUninforms() {
|
|
94
|
-
return {};
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "initModels",
|
|
98
|
-
value: function initModels() {
|
|
99
|
-
var _this$tilesetManager;
|
|
100
|
-
|
|
101
|
-
var source = this.layer.getSource();
|
|
102
|
-
this.tilesetManager = source.tileset;
|
|
103
|
-
|
|
104
|
-
if (!this.initedTileset) {
|
|
105
|
-
this.bindTilesetEvent();
|
|
106
|
-
this.initedTileset = true;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var _this$getCurrentView = this.getCurrentView(),
|
|
110
|
-
latLonBounds = _this$getCurrentView.latLonBounds,
|
|
111
|
-
zoom = _this$getCurrentView.zoom;
|
|
112
|
-
|
|
113
|
-
(_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.update(zoom, latLonBounds);
|
|
114
|
-
|
|
115
|
-
if (this.showGrid) {
|
|
116
|
-
this.renderSubGridLayer();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this.buildModels();
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "buildModels",
|
|
123
|
-
value: function buildModels() {
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
key: "clearModels",
|
|
128
|
-
value: function clearModels() {}
|
|
129
|
-
}, {
|
|
130
|
-
key: "renderSubGridLayer",
|
|
131
|
-
value: function renderSubGridLayer() {
|
|
132
|
-
if (!this.tilesetManager) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
var features = this.tilesetManager.currentTiles.map(function (tile) {
|
|
137
|
-
return tile.bboxPolygon;
|
|
138
|
-
});
|
|
139
|
-
var data = {
|
|
140
|
-
type: 'FeatureCollection',
|
|
141
|
-
features: features
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if (this.subGridLayer) {
|
|
145
|
-
this.subGridLayer.setData(data);
|
|
146
|
-
this.subTextLayer.setData(data);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
this.subGridLayer = new LineLayer({
|
|
151
|
-
autoFit: false
|
|
152
|
-
}).source(data).size(1).color('red').shape('simple').style({
|
|
153
|
-
lineType: 'dash',
|
|
154
|
-
dashArray: [1, 2]
|
|
155
|
-
});
|
|
156
|
-
this.subTextLayer = new PointLayer({
|
|
157
|
-
autoFit: false
|
|
158
|
-
}).source(data).size(14).color('red').shape('meta', 'text').style({
|
|
159
|
-
opacity: 1,
|
|
160
|
-
strokeWidth: 1,
|
|
161
|
-
stroke: '#fff'
|
|
162
|
-
});
|
|
163
|
-
this.subGridLayer.setContainer(createLayerContainer(this.layer.sceneContainer), this.layer.sceneContainer);
|
|
164
|
-
this.subTextLayer.setContainer(createLayerContainer(this.layer.sceneContainer), this.layer.sceneContainer);
|
|
165
|
-
this.subGridLayer.init();
|
|
166
|
-
this.subTextLayer.init();
|
|
167
|
-
}
|
|
168
|
-
}, {
|
|
169
|
-
key: "registerBuiltinAttributes",
|
|
170
|
-
value: function registerBuiltinAttributes() {}
|
|
171
|
-
}, {
|
|
172
|
-
key: "bindTilesetEvent",
|
|
173
|
-
value: function bindTilesetEvent() {
|
|
174
|
-
var _this2 = this;
|
|
175
|
-
|
|
176
|
-
if (!this.tilesetManager) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
this.tilesetManager.on('tile-loaded', function (tile) {});
|
|
181
|
-
this.tilesetManager.on('tile-unload', function (tile) {
|
|
182
|
-
_this2.destroySubLayer(tile);
|
|
183
|
-
});
|
|
184
|
-
this.tilesetManager.on('tile-error', function (error, tile) {});
|
|
185
|
-
this.tilesetManager.on('tile-update', this.renderSubLayers);
|
|
186
|
-
this.mapService.on('mapchange', function (e) {
|
|
187
|
-
var _this2$getCurrentView = _this2.getCurrentView(),
|
|
188
|
-
latLonBounds = _this2$getCurrentView.latLonBounds,
|
|
189
|
-
zoom = _this2$getCurrentView.zoom;
|
|
190
|
-
|
|
191
|
-
if (_this2.mapService.version === 'GAODE1.x') {
|
|
192
|
-
var _this2$layer$getLayer = _this2.layer.getLayerConfig(),
|
|
193
|
-
visible = _this2$layer$getLayer.visible;
|
|
194
|
-
|
|
195
|
-
if (zoom < 3 && visible) {
|
|
196
|
-
_this2.layer.updateLayerConfig({
|
|
197
|
-
visible: false
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
_this2.layerService.updateLayerRenderList();
|
|
201
|
-
} else if (zoom >= 3 && !visible) {
|
|
202
|
-
_this2.layer.updateLayerConfig({
|
|
203
|
-
visible: true
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
_this2.layerService.updateLayerRenderList();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (_this2.lastViewStates && _this2.lastViewStates.zoom === zoom && _this2.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
_this2.lastViewStates = {
|
|
215
|
-
zoom: zoom,
|
|
216
|
-
latLonBounds: latLonBounds
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
if (_this2.timer) {
|
|
220
|
-
clearTimeout(_this2.timer);
|
|
221
|
-
_this2.timer = null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
_this2.timer = setTimeout(function () {
|
|
225
|
-
var _this2$tilesetManager;
|
|
226
|
-
|
|
227
|
-
(_this2$tilesetManager = _this2.tilesetManager) === null || _this2$tilesetManager === void 0 ? void 0 : _this2$tilesetManager.update(zoom, latLonBounds);
|
|
228
|
-
|
|
229
|
-
if (_this2.showGrid) {
|
|
230
|
-
_this2.renderSubGridLayer();
|
|
231
|
-
}
|
|
232
|
-
}, 250);
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}, {
|
|
236
|
-
key: "creatSubLayer",
|
|
237
|
-
value: function creatSubLayer(tile) {
|
|
238
|
-
var _ref = this.layer.getLayerConfig(),
|
|
239
|
-
_ref$opacity = _ref.opacity,
|
|
240
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
241
|
-
_ref$zIndex = _ref.zIndex,
|
|
242
|
-
zIndex = _ref$zIndex === void 0 ? 0 : _ref$zIndex;
|
|
243
|
-
|
|
244
|
-
var layer = new ImageLayer({
|
|
245
|
-
visible: tile.isVisible,
|
|
246
|
-
zIndex: zIndex
|
|
247
|
-
}).source(tile.data, {
|
|
248
|
-
parser: {
|
|
249
|
-
type: 'image',
|
|
250
|
-
extent: tile.bounds
|
|
251
|
-
}
|
|
252
|
-
}).style({
|
|
253
|
-
opacity: opacity
|
|
254
|
-
});
|
|
255
|
-
var container = createLayerContainer(this.layer.sceneContainer);
|
|
256
|
-
layer.setContainer(container, this.layer.sceneContainer);
|
|
257
|
-
layer.init();
|
|
258
|
-
return layer;
|
|
259
|
-
}
|
|
260
|
-
}, {
|
|
261
|
-
key: "destroySubLayer",
|
|
262
|
-
value: function destroySubLayer(tile) {
|
|
263
|
-
if (tile.layer) {
|
|
264
|
-
var layerGroup = this.layer;
|
|
265
|
-
layerGroup.removeChild(tile.layer);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}, {
|
|
269
|
-
key: "getCurrentView",
|
|
270
|
-
value: function getCurrentView() {
|
|
271
|
-
var bounds = this.mapService.getBounds();
|
|
272
|
-
var latLonBounds = [bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]];
|
|
273
|
-
var zoom = this.mapService.getZoom();
|
|
274
|
-
return {
|
|
275
|
-
latLonBounds: latLonBounds,
|
|
276
|
-
zoom: zoom
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
}]);
|
|
280
|
-
|
|
281
|
-
return RasterTileModel;
|
|
282
|
-
}(BaseModel);
|
|
283
|
-
|
|
284
|
-
export { RasterTileModel as default };
|
|
285
|
-
//# sourceMappingURL=raste-tile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/raster/models/raste-tile.ts"],"names":["createLayerContainer","BaseModel","ImageLayer","LineLayer","PointLayer","RasterTileModel","tilesetManager","rasteTileLayer","layer","tiles","filter","tile","isLoaded","map","creatSubLayer","addChild","updateLayerConfig","visible","isVisible","showGrid","hasChild","subGridLayer","subTextLayer","layerService","renderLayers","emit","currentTiles","source","getSource","tileset","initedTileset","bindTilesetEvent","getCurrentView","latLonBounds","zoom","update","renderSubGridLayer","buildModels","features","bboxPolygon","data","type","setData","autoFit","size","color","shape","style","lineType","dashArray","opacity","strokeWidth","stroke","setContainer","sceneContainer","init","on","destroySubLayer","error","renderSubLayers","mapService","e","version","getLayerConfig","updateLayerRenderList","lastViewStates","toString","timer","clearTimeout","setTimeout","zIndex","parser","extent","bounds","container","layerGroup","removeChild","getBounds","getZoom"],"mappings":";;;;;;;;;;;;AAAA,SACEA,oBADF,QAKO,eALP;AAQA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,OAAOC,UAAP,MAAuB,aAAvB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,aAAvB;;IAEqBC,e;;;;;;;;;;;;;;;;oEAEI,K;;;;+DAIL,K;;;;;;;;;;sEA0LQ,YAAM;AAC9B,UAAI,CAAC,MAAKC,cAAV,EAA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wC,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CADqD,EAErDA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAFqD,EAGrDA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAHqD,EAIrDA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAJqD,CAAvD;AAMA,UAAMvC,IAAI,GAAG,KAAK0B,UAAL,CAAgBkB,OAAhB,EAAb;AAEA,aAAO;AAAE7C,QAAAA,YAAY,EAAZA,YAAF;AAAgBC,QAAAA,IAAI,EAAJA;AAAhB,OAAP;AACD;;;;EA3P0CjC,S;;SAAxBI,e","sourcesContent":["import {\n createLayerContainer,\n ILayer,\n ILayerGroup,\n IModelUniform,\n} from '@antv/l7-core';\nimport { Tile, TilesetManager } from '@antv/l7-utils';\nimport { Container } from 'inversify';\nimport BaseModel from '../../core/BaseModel';\nimport { IRasterTileLayerStyleOptions } from '../../core/interface';\nimport ImageLayer from '../../image';\nimport LineLayer from '../../line';\nimport PointLayer from '../../point';\n\nexport default class RasterTileModel extends BaseModel {\n // 瓦片是否加载成功\n public initedTileset = false;\n // 瓦片数据管理器\n public tilesetManager: TilesetManager | undefined;\n // 是否开启瓦片网格子图层,用于调试\n public showGrid = false;\n // 瓦片网格子图层,用于调试\n private subGridLayer: ILayer;\n // 瓦片网格文本子图层,用于调试\n private subTextLayer: ILayer;\n // 上一次视野状态\n private lastViewStates: {\n zoom: number;\n latLonBounds: [number, number, number, number];\n };\n private timer: any;\n\n public getUninforms(): IModelUniform {\n return {};\n }\n\n public initModels() {\n const source = this.layer.getSource();\n this.tilesetManager = source.tileset;\n\n if (!this.initedTileset) {\n this.bindTilesetEvent();\n this.initedTileset = true;\n }\n\n const { latLonBounds, zoom } = this.getCurrentView();\n this.tilesetManager?.update(zoom, latLonBounds);\n\n if (this.showGrid) {\n this.renderSubGridLayer();\n }\n\n return this.buildModels();\n }\n\n public buildModels() {\n return [];\n }\n\n public clearModels() {\n //\n }\n\n // 渲染瓦片网格图层方便调试\n public renderSubGridLayer() {\n if (!this.tilesetManager) {\n return;\n }\n\n const features = this.tilesetManager.currentTiles.map(\n (tile) => tile.bboxPolygon,\n );\n\n const data = { type: 'FeatureCollection', features };\n\n if (this.subGridLayer) {\n this.subGridLayer.setData(data);\n this.subTextLayer.setData(data);\n return;\n }\n\n this.subGridLayer = new LineLayer({ autoFit: false })\n .source(data)\n .size(1)\n .color('red')\n .shape('simple')\n .style({ lineType: 'dash', dashArray: [1, 2] });\n\n this.subTextLayer = new PointLayer({ autoFit: false })\n .source(data)\n .size(14)\n .color('red')\n .shape('meta', 'text')\n .style({\n opacity: 1,\n strokeWidth: 1,\n stroke: '#fff',\n });\n\n this.subGridLayer.setContainer(\n createLayerContainer(this.layer.sceneContainer as Container),\n this.layer.sceneContainer as Container,\n );\n this.subTextLayer.setContainer(\n createLayerContainer(this.layer.sceneContainer as Container),\n this.layer.sceneContainer as Container,\n );\n this.subGridLayer.init();\n this.subTextLayer.init();\n }\n\n protected registerBuiltinAttributes() {\n //\n }\n\n // 监听瓦片管理器\n private bindTilesetEvent() {\n if (!this.tilesetManager) {\n return;\n }\n // 瓦片数据加载成功\n this.tilesetManager.on('tile-loaded', (tile: Tile) => {\n // todo: 将事件抛出,图层上可以监听使用\n });\n\n // 瓦片数据从缓存删除或被执行重新加载\n this.tilesetManager.on('tile-unload', (tile: Tile) => {\n // todo: 将事件抛出,图层上可以监听使用\n this.destroySubLayer(tile);\n });\n\n // 瓦片数据加载失败\n this.tilesetManager.on('tile-error', (error, tile: Tile) => {\n // todo: 将事件抛出,图层上可以监听使用\n });\n\n // 瓦片显隐状态更新\n this.tilesetManager.on('tile-update', this.renderSubLayers);\n\n // 地图视野发生改变\n this.mapService.on('mapchange', (e) => {\n const { latLonBounds, zoom } = this.getCurrentView();\n\n if (this.mapService.version === 'GAODE1.x') {\n const { visible } = this.layer.getLayerConfig();\n if (zoom < 3 && visible) {\n this.layer.updateLayerConfig({ visible: false });\n this.layerService.updateLayerRenderList();\n } else if (zoom >= 3 && !visible) {\n this.layer.updateLayerConfig({ visible: true });\n this.layerService.updateLayerRenderList();\n }\n }\n\n if (\n this.lastViewStates &&\n this.lastViewStates.zoom === zoom &&\n this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()\n ) {\n return;\n }\n this.lastViewStates = { zoom, latLonBounds };\n\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n\n this.timer = setTimeout(() => {\n this.tilesetManager?.update(zoom, latLonBounds);\n if (this.showGrid) {\n this.renderSubGridLayer();\n }\n }, 250);\n });\n }\n\n // 创建子图层\n private creatSubLayer(tile: Tile) {\n const {\n opacity = 1,\n zIndex = 0,\n } = this.layer.getLayerConfig() as IRasterTileLayerStyleOptions;\n const layer = new ImageLayer({\n visible: tile.isVisible,\n zIndex,\n })\n .source(tile.data, {\n parser: {\n type: 'image',\n extent: tile.bounds,\n },\n })\n .style({\n opacity,\n });\n const container = createLayerContainer(\n this.layer.sceneContainer as Container,\n );\n layer.setContainer(container, this.layer.sceneContainer as Container);\n layer.init();\n\n return layer;\n }\n\n // 更新子图层\n private renderSubLayers = () => {\n if (!this.tilesetManager) {\n return;\n }\n\n const rasteTileLayer = this.layer as ILayerGroup;\n\n this.tilesetManager.tiles\n .filter((tile) => tile.isLoaded)\n .map((tile) => {\n if (!tile.layer) {\n tile.layer = this.creatSubLayer(tile);\n rasteTileLayer.addChild(tile.layer);\n } else {\n // 显隐藏控制\n tile.layer.updateLayerConfig({\n visible: tile.isVisible,\n });\n }\n return tile.layer;\n });\n\n if (this.showGrid) {\n if (!rasteTileLayer.hasChild(this.subGridLayer)) {\n rasteTileLayer.addChild(this.subGridLayer);\n }\n if (!rasteTileLayer.hasChild(this.subTextLayer)) {\n rasteTileLayer.addChild(this.subTextLayer);\n }\n }\n\n this.layerService.renderLayers();\n\n if (this.tilesetManager.isLoaded) {\n // 将事件抛出,图层上可以使用瓦片\n rasteTileLayer.emit('tiles-loaded', this.tilesetManager.currentTiles);\n }\n };\n\n // 摧毁子图层\n private destroySubLayer(tile: Tile) {\n if (tile.layer) {\n const layerGroup = this.layer as ILayerGroup;\n layerGroup.removeChild(tile.layer);\n }\n }\n\n // 获取当前视野参数\n private getCurrentView() {\n const bounds = this.mapService.getBounds();\n const latLonBounds: [number, number, number, number] = [\n bounds[0][0],\n bounds[0][1],\n bounds[1][0],\n bounds[1][1],\n ];\n const zoom = this.mapService.getZoom();\n\n return { latLonBounds, zoom };\n }\n}\n"],"file":"raste-tile.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/LayerGroup.ts"],"names":["LayerGroup","layer","layerChildren","push","layerIndex","indexOf","splice","destroy","forEach","includes","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;;IAIqBA,U;;;;;;;;;;;;;;;+FAGY,I;;;;;;WAE/B,kBAAgBC,KAAhB,EAA+B;AAC7B,WAAKC,aAAL,CAAmBC,IAAnB,CAAwBF,KAAxB;AACD;;;WAED,qBAAmBA,KAAnB,EAAkC;AAChC,UAAMG,UAAU,GAAG,KAAKF,aAAL,CAAmBG,OAAnB,CAA2BJ,KAA3B,CAAnB;;AACA,UAAIG,UAAU,GAAG,CAAC,CAAlB,EAAqB;AACnB,aAAKF,aAAL,CAAmBI,MAAnB,CAA0BF,UAA1B,EAAsC,CAAtC;AACD;;AACDH,MAAAA,KAAK,CAACM,OAAN;AACD;;;WAED,sBAAoB;AAClB,WAAKL,aAAL,CAAmBM,OAAnB,CAA2B,UAACP,KAAD,EAAgB;AACzCA,QAAAA,KAAK,CAACM,OAAN;AACD,OAFD;AAIA,WAAKL,aAAL,GAAqB,EAArB;AACD;;;WAED,kBAAgBD,KAAhB,EAA+B;AAC7B,aAAO,KAAKC,aAAL,CAAmBO,QAAnB,CAA4BR,KAA5B,CAAP;AACD;;;EA1BOS,mB","sourcesContent":["import { ILayer, ILayerGroup } from '@antv/l7-core';\nimport BaseLayer from './BaseLayer';\n\n// 定义 LayerGroup 继承 Baselayer\n\nexport default class LayerGroup<ChildLayerStyleOptions = {}>\n extends BaseLayer<ChildLayerStyleOptions>\n implements ILayerGroup {\n public isLayerGroup: boolean = true;\n\n public addChild(layer: ILayer) {\n this.layerChildren.push(layer);\n }\n\n public removeChild(layer: ILayer) {\n const layerIndex = this.layerChildren.indexOf(layer);\n if (layerIndex > -1) {\n this.layerChildren.splice(layerIndex, 1);\n }\n layer.destroy();\n }\n\n public clearChild() {\n this.layerChildren.forEach((layer: any) => {\n layer.destroy();\n });\n\n this.layerChildren = [];\n }\n\n public hasChild(layer: ILayer) {\n return this.layerChildren.includes(layer);\n }\n}\n"],"file":"LayerGroup.js"}
|