更改问题

This commit is contained in:
zengmingjie 2025-07-08 22:33:58 +08:00
parent 4457c08192
commit b4f8356eb5
3 changed files with 111 additions and 62 deletions

View File

@ -1,3 +1,4 @@
my-form
<template>
<div class="my-form">
<el-form
@ -423,7 +424,7 @@ export default {
}
if (newVal.geojson === undefined) {
if (this.$refs.myMarsmap !== undefined) {
this.$refs.myMarsmap[0].clearDraw();
// this.$refs.myMarsmap[0].clearDraw();
}
}
}
@ -536,37 +537,77 @@ export default {
};
if (this.$refs.myMarsmap) {
let toJson = this.$refs.myMarsmap[0].toGeoJSON();
//
geojson.coordinates = toJson.features.map((item) => {
if (item.properties.type === "polygon") {
item.geometry.coordinates[0][
item.geometry.coordinates[0].length
] = item.geometry.coordinates[0][0];
} else if (item.properties.type === "pointP") {
console.log(item.geometry.coordinates);
} else if (item.properties.type === "circle") {
// eslint-disable-next-line no-undef
const positions = mars3d.PolyUtil.getEllipseOuterPositions({
position: item.geometry.coordinates,
radius: item.properties.style.radius
});
item.geometry.coordinates = [[]];
positions.forEach((el) => {
// eslint-disable-next-line no-undef
mars3d.LngLatPoint.fromCartesian(el).toArray(),
if (toJson.features.length !== 0) {
console.log(toJson, "toJson");
//
geojson.coordinates = toJson.features.map((item) => {
if (item.properties.type === "polygon") {
// coordinates
if (
Array.isArray(item.geometry.coordinates) &&
Array.isArray(item.geometry.coordinates[0]) &&
Array.isArray(item.geometry.coordinates[0][0])
) {
let coords = item.geometry.coordinates[0];
if (coords.length > 1) {
let firstCoord = coords[0];
let lastCoord = coords[coords.length - 1];
//
while (
coords.length > 1 &&
lastCoord[0] === firstCoord[0] &&
lastCoord[1] === firstCoord[1]
) {
coords.pop();
// lastCoord
if (coords.length > 1) {
lastCoord = coords[coords.length - 1];
}
}
//
if (
coords.length > 1 &&
(firstCoord[0] !== lastCoord[0] ||
firstCoord[1] !== lastCoord[1])
) {
//
item.geometry.coordinates[0].push(firstCoord);
}
}
}
} else if (item.properties.type === "pointP") {
console.log(item.geometry.coordinates, "112233");
} else if (item.properties.type === "circle") {
const positions = mars3d.PolyUtil.getEllipseOuterPositions({
position: item.geometry.coordinates,
radius: item.properties.style.radius
});
item.geometry.coordinates = [[]];
positions.forEach((el) => {
item.geometry.coordinates[0].push(
// eslint-disable-next-line no-undef
mars3d.LngLatPoint.fromCartesian(el).toArray()
);
});
console.log(item.geometry.coordinates);
item.geometry.coordinates[0].push(
item.geometry.coordinates[0][0]
);
// console.log(item.geometry.coordinates);
}
return item.geometry.coordinates;
});
});
console.log(item.geometry.coordinates);
//
if (item.geometry.coordinates[0].length > 0) {
item.geometry.coordinates[0].push(
item.geometry.coordinates[0][0]
);
}
}
return item.geometry.coordinates;
});
geojson.coordinates = geojson.coordinates.filter(
(item) =>
Array.isArray(item) &&
Array.isArray(item[0]) &&
Array.isArray(item[0][0])
);
}
this.ruleForm.geoJson = geojson;
this.ruleForm.center = [
this.$refs.myMarsmap[0].lonData,

View File

@ -1,3 +1,4 @@
myMarsmap
<template>
<div class="ditu">
<div id="marsContainer-map" ref="marsMaps" class="mars3d-container"></div>
@ -99,12 +100,11 @@ export default {
deep: true,
immediate: true,
handler(newVal) {
console.log("newVal1111", newVal);
if (newVal) {
this.jsonData = JSON.parse(newVal);
if (this.jsonData) {
if (newVal) {
this.showRegion(this.jsonData, "geojson");
}
this.showRegion(this.jsonData, "geojson");
}
}
}
@ -121,9 +121,9 @@ export default {
this.lonData = "";
this.latData = "";
}
console.log("mapData发生变化", newVal);
if (this.lonData && this.latData) {
if (this.lonData && this.latData) {
this.isinputDisabled = true;
this.deviceDrid(this.lonData, this.latData);
}
}
@ -217,6 +217,7 @@ export default {
}
if (this.lonData && this.latData) {
this.deviceDrid(this.lonData, this.latData);
this.isinputDisabled = true;
}
},
lineClicks(val) {
@ -334,9 +335,8 @@ export default {
}
},
toGeoJSON() {
console.log(this.graphicLayer, this.typeOf, "this.graphicLayer");
if (this.typeOf === "pointP") {
return this.graphicLayer.toGeoJSON({ noAlt: true });
// return this.graphicLayer.toGeoJSON({ noAlt: true });
} else {
this.graphicLayer._graphicList._array.forEach((item) => {
if (item.type === "billboard") {
@ -347,6 +347,7 @@ export default {
}
},
showRegion(value, type) {
this.clearDraw();
let geojson = {};
if (type === "uploadGeojson") {
if (this.graphicLayer._graphicList.length === 0) {
@ -387,7 +388,6 @@ export default {
}
},
deviceDrid(lon, lat) {
// this.clearDraw();
console.log(this.graphicLayer, "this.graphicLayer");
if (this.graphicLayer) {
this.graphicLayer.eachGraphic((item) => {

View File

@ -1,3 +1,4 @@
PositionDialog
<template>
<div class="position">
<div class="demo-formName">
@ -216,40 +217,47 @@ export default {
},
//
determine(value) {
let params = {};
params = value;
let params = { ...value };
console.log(params, "params");
params.regionJson = JSON.stringify(params.geoJson);
if (params.geoJson.coordinates.length !== 0) {
params.regionJson = JSON.stringify(params.geoJson);
params.lon = params.center[0];
params.lat = params.center[1];
this.$delete(params, "geoJson");
this.$delete(params, "center");
// this.$delete(params, "imageBriefUrl");
if (params.lon !== "" && params.lat !== "") {
if (this.isType === "add") {
// console.log("");
devPositionAdd(params)
.then((res) => {
params.lon = params.center[0];
params.lat = params.center[1];
this.$delete(params, "geoJson");
this.$delete(params, "center");
// this.$delete(params, "imageBriefUrl");
if (params.lon !== "" && params.lat !== "") {
if (this.isType === "add") {
// console.log("");
devPositionAdd(params)
.then((res) => {
if (res.code === 0) {
this.$message.success("新增成功");
this.headdenForm({}, "search");
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
console.log(err);
});
} else if (this.isType === "edit") {
devPositionUpdate(params).then((res) => {
if (res.code === 0) {
this.$message.success("新增成功");
this.$message.success("编辑成功");
this.headdenForm({}, "search");
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
console.log(err);
});
} else if (this.isType === "edit") {
devPositionUpdate(params).then((res) => {
if (res.code === 0) {
this.$message.success("编辑成功");
this.headdenForm({}, "search");
}
});
}
this.drawer = false;
} else {
this.$message.error("请选择地图上的经纬度");
}
this.drawer = false;
} else {
this.$message.error("请选择地图上的经纬度");
this.$message.error("请绘制地图上的防区");
}
},
//