diff --git a/src/common/mapping/WebMapV2.js b/src/common/mapping/WebMapV2.js index 0def615b0..c0ba474ba 100644 --- a/src/common/mapping/WebMapV2.js +++ b/src/common/mapping/WebMapV2.js @@ -61,6 +61,8 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) { super.cleanLayers(layers); this.echartslayer.forEach(echartLayer => { echartLayer.remove(); + echartLayer.features = null; + echartLayer.id = ''; }); } @@ -1106,6 +1108,8 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) { options.GLMap = { roam: true }; const echartslayer = new window.EchartsLayer(this.map); echartslayer.chart.setOption(options); + echartslayer.id = layerID; + echartslayer.features = features; this.echartslayer.push(echartslayer); this._addLayer({ id: layerID, diff --git a/src/common/mapping/WebMapV2Base.js b/src/common/mapping/WebMapV2Base.js index db2db91a8..cbdae14ec 100644 --- a/src/common/mapping/WebMapV2Base.js +++ b/src/common/mapping/WebMapV2Base.js @@ -495,6 +495,10 @@ export function createWebMapV2BaseExtending(SuperClass = Events, fireField = 'tr const options = this._createOptions(layerInfo, lineData, pointData, coordinateSystem); return options; } + + getEchartsLayerById(layerId) { + return this.echartsLayer.find(layer => layer.layerId === layerId); + } getDashStyle(str, strokeWidth = 1, type = 'array') { if (!str) { diff --git a/src/common/overlay/l7/L7LayerBase.js b/src/common/overlay/l7/L7LayerBase.js index 701eddf9b..a7fc65ca8 100644 --- a/src/common/overlay/l7/L7LayerBase.js +++ b/src/common/overlay/l7/L7LayerBase.js @@ -193,6 +193,10 @@ export class L7LayerBase extends CustomOverlayLayer { type: parser.type, map: this.map }; + if (parser.extent) { + sourceInfo.bounds = parser.extent; + } + let formatData = []; switch (parser.type) { case 'mvt': sourceInfo.type = 'vector'; @@ -202,6 +206,26 @@ export class L7LayerBase extends CustomOverlayLayer { sourceInfo.getData = () => layerSource.originData; sourceInfo.setData = this.setDataFn; break; + case 'json': + formatData = (layerSource.originData || []).map((feature) => { + return { + type: 'Feature', + geometry: { + coordinates: [feature[parser.x], feature[parser.y]], + type: 'Point' + }, + properties: { + ...feature + } + } + }); + sourceInfo.getData = () => { + return { + type: 'FeatureCollection', + features: formatData + } + }; + break; } return sourceInfo; }