|
@@ -327,7 +327,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
handleDownload() {
|
|
handleDownload() {
|
|
|
- let zipfile = this.newObj.proxypath + ".zip";
|
|
|
|
|
|
|
+ const zipfile = this.newObj.proxypath + ".zip";
|
|
|
window.open(`${zipfile}`);
|
|
window.open(`${zipfile}`);
|
|
|
},
|
|
},
|
|
|
tableClick(row) {
|
|
tableClick(row) {
|
|
@@ -387,61 +387,51 @@ export default {
|
|
|
this.drawer = false;
|
|
this.drawer = false;
|
|
|
},
|
|
},
|
|
|
test(item) {
|
|
test(item) {
|
|
|
- // 1. 提取公共样式配置,避免重复定义
|
|
|
|
|
let highlightStyle = new Style({
|
|
let highlightStyle = new Style({
|
|
|
stroke: new Stroke({
|
|
stroke: new Stroke({
|
|
|
color: "rgba(255, 0, 0, 1)",
|
|
color: "rgba(255, 0, 0, 1)",
|
|
|
width: 2,
|
|
width: 2,
|
|
|
}),
|
|
}),
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- // 2. 确定当前操作的地图容器列表
|
|
|
|
|
let mapNames = this.sjlx === 1 ? ["mapDiv"] : ["mapCon1", "mapCon2"];
|
|
let mapNames = this.sjlx === 1 ? ["mapDiv"] : ["mapCon1", "mapCon2"];
|
|
|
-
|
|
|
|
|
- // 3. 清除所有相关地图容器中的旧高亮图层
|
|
|
|
|
mapNames.forEach((mapName) => {
|
|
mapNames.forEach((mapName) => {
|
|
|
if (this.itemObj && window.map[mapName]) {
|
|
if (this.itemObj && window.map[mapName]) {
|
|
|
window.map[mapName].removeLayer(this.itemObj);
|
|
window.map[mapName].removeLayer(this.itemObj);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- // 4. 验证geom数据有效性
|
|
|
|
|
if (!item.geom || item.geom === "") return;
|
|
if (!item.geom || item.geom === "") return;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- // 5. 统一处理geom格式转换
|
|
|
|
|
let geomData = item.geom;
|
|
let geomData = item.geom;
|
|
|
if (typeof geomData === "string") {
|
|
if (typeof geomData === "string") {
|
|
|
geomData = parse(geomData);
|
|
geomData = parse(geomData);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 6. 创建矢量图层
|
|
|
|
|
let features = new GeoJSON().readFeatures(geomData);
|
|
let features = new GeoJSON().readFeatures(geomData);
|
|
|
this.itemObj = new VectorLayer({
|
|
this.itemObj = new VectorLayer({
|
|
|
source: new VectorSource({ features }),
|
|
source: new VectorSource({ features }),
|
|
|
style: highlightStyle,
|
|
style: highlightStyle,
|
|
|
zIndex: 9999,
|
|
zIndex: 9999,
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- // 7. 获取实体地理范围(优先使用geom范围,而非中心点)
|
|
|
|
|
let extent = this.itemObj.getSource().getExtent();
|
|
let extent = this.itemObj.getSource().getExtent();
|
|
|
- if (!extent || extent.length !== 4) {
|
|
|
|
|
- console.warn("无效的实体范围:", extent);
|
|
|
|
|
|
|
+ if (!extent) {
|
|
|
|
|
+ console.warn("无法获取实体范围,无法执行飞入动画");
|
|
|
|
|
+ // 仅添加图层不执行动画
|
|
|
|
|
+ mapNames.forEach((mapName) => {
|
|
|
|
|
+ let map = window.map[mapName];
|
|
|
|
|
+ if (map) map.addLayer(this.itemObj);
|
|
|
|
|
+ });
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 8. 对所有相关地图执行添加图层和基于实体范围的飞入动画
|
|
|
|
|
|
|
+ //对所有相关地图执行添加图层和基于范围的飞入动画
|
|
|
mapNames.forEach((mapName) => {
|
|
mapNames.forEach((mapName) => {
|
|
|
let map = window.map[mapName];
|
|
let map = window.map[mapName];
|
|
|
if (map) {
|
|
if (map) {
|
|
|
- // 添加新图层
|
|
|
|
|
map.addLayer(this.itemObj);
|
|
map.addLayer(this.itemObj);
|
|
|
- // 基于实体范围的飞入动画(仅在第一个地图执行一次)
|
|
|
|
|
if (mapName === mapNames[0]) {
|
|
if (mapName === mapNames[0]) {
|
|
|
map.getView().fit(extent, {
|
|
map.getView().fit(extent, {
|
|
|
- duration: 2000, // 动画持续时间
|
|
|
|
|
- padding: [50, 50, 50, 50], // 边界内边距,避免实体贴边
|
|
|
|
|
- maxZoom: 16.5, // 最大缩放级别限制
|
|
|
|
|
|
|
+ duration: 2000,
|
|
|
|
|
+ callback: null,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|