Skip to content

Commit

Permalink
修复webmap od 图不支持缩放至图层
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Oct 16, 2024
1 parent 12fc838 commit 00aeb71
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/common/mapping/WebMapV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
super.cleanLayers(layers);
this.echartslayer.forEach(echartLayer => {
echartLayer.remove();
echartLayer.features = null;
echartLayer.id = '';
});
}

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/common/mapping/WebMapV2Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 24 additions & 0 deletions src/common/overlay/l7/L7LayerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
Expand Down

0 comments on commit 00aeb71

Please sign in to comment.