|
|
@@ -72,7 +72,11 @@ import Stroke from "ol/style/Stroke";
|
|
|
import { Style, Icon } from "ol/style";
|
|
|
import { fromLonLat } from "ol/proj";
|
|
|
import { get as getProjection } from "ol/proj";
|
|
|
-import { getAttributesById, intersects } from "@/api/ghfxpj/cyfxApi.js";
|
|
|
+import {
|
|
|
+ getAttributesById,
|
|
|
+ intersects,
|
|
|
+ getGeomById,
|
|
|
+} from "@/api/ghfxpj/cyfxApi.js";
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -179,32 +183,59 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
postion(data) {
|
|
|
+ // 先清除已有图层
|
|
|
ghcyfx.delPos();
|
|
|
+
|
|
|
+ // 定义高亮样式
|
|
|
let highlightStyle = new Style({
|
|
|
stroke: new Stroke({
|
|
|
color: "rgba(255, 0, 0, 1)",
|
|
|
width: 2,
|
|
|
}),
|
|
|
});
|
|
|
- let geomData = data;
|
|
|
- if (typeof geomData === "string") {
|
|
|
- geomData = parse(geomData);
|
|
|
- }
|
|
|
- let features = new GeoJSON().readFeatures(geomData, {
|
|
|
- dataProjection: getProjection("EPSG:4326"),
|
|
|
- featureProjection: getProjection("EPSG:3857"),
|
|
|
- });
|
|
|
- ghcyfx.itemObj = new VectorLayer({
|
|
|
- source: new VectorSource({ features }),
|
|
|
- style: highlightStyle,
|
|
|
- zIndex: 9999,
|
|
|
- });
|
|
|
- let extent = ghcyfx.itemObj.getSource().getExtent();
|
|
|
- arcMap.addLayer(ghcyfx.itemObj);
|
|
|
- arcMap.map.getView().fit(extent, {
|
|
|
- duration: 2000,
|
|
|
- callback: null,
|
|
|
+
|
|
|
+ // 处理数据为数组的情况
|
|
|
+ let geomArray = Array.isArray(data) ? data : [data];
|
|
|
+ let allFeatures = [];
|
|
|
+
|
|
|
+ geomArray.forEach((geomItem) => {
|
|
|
+ try {
|
|
|
+ let geomData = geomItem;
|
|
|
+ // 解析WKT格式字符串
|
|
|
+ if (typeof geomData === "string") {
|
|
|
+ geomData = parse(geomData);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 读取要素并转换投影
|
|
|
+ let features = new GeoJSON().readFeatures(geomData, {
|
|
|
+ dataProjection: getProjection("EPSG:4326"),
|
|
|
+ featureProjection: getProjection("EPSG:3857"),
|
|
|
+ });
|
|
|
+
|
|
|
+ allFeatures.push(...features);
|
|
|
+ } catch (error) {
|
|
|
+ console.error("解析地理数据出错", error, "数据项:", geomItem);
|
|
|
+ }
|
|
|
});
|
|
|
+
|
|
|
+ // 创建矢量图层并添加要素
|
|
|
+ if (allFeatures.length > 0) {
|
|
|
+ ghcyfx.itemObj = new VectorLayer({
|
|
|
+ source: new VectorSource({ features: allFeatures }),
|
|
|
+ style: highlightStyle,
|
|
|
+ zIndex: 9999,
|
|
|
+ });
|
|
|
+
|
|
|
+ // 添加图层并调整视图范围
|
|
|
+ arcMap.addLayer(ghcyfx.itemObj);
|
|
|
+ const extent = ghcyfx.itemObj.getSource().getExtent();
|
|
|
+ if (extent) {
|
|
|
+ arcMap.map.getView().fit(extent, {
|
|
|
+ duration: 2000,
|
|
|
+ callback: null,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
dblClick(row, column, cell, event) {
|
|
|
intersects({ id: ghcyfx.transfer.id, objectid: row["编号"] }).then(
|
|
|
@@ -227,6 +258,15 @@ export default {
|
|
|
ghcyfx.showTable = false;
|
|
|
ghcyfx.delPos();
|
|
|
}
|
|
|
+ if (newvalue.showBrowsing) {
|
|
|
+ getGeomById({ id: newvalue.id }).then((res) => {
|
|
|
+ if (res.statuscode === 200) {
|
|
|
+ ghcyfx.postion(res.data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ ghcyfx.delPos();
|
|
|
+ }
|
|
|
}
|
|
|
);
|
|
|
watch(
|