更改问题
This commit is contained in:
		
							parent
							
								
									4457c08192
								
							
						
					
					
						commit
						b4f8356eb5
					
				| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					my-form
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="my-form">
 | 
					  <div class="my-form">
 | 
				
			||||||
    <el-form
 | 
					    <el-form
 | 
				
			||||||
| 
						 | 
					@ -423,7 +424,7 @@ export default {
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          if (newVal.geojson === undefined) {
 | 
					          if (newVal.geojson === undefined) {
 | 
				
			||||||
            if (this.$refs.myMarsmap !== 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) {
 | 
					          if (this.$refs.myMarsmap) {
 | 
				
			||||||
            let toJson = this.$refs.myMarsmap[0].toGeoJSON();
 | 
					            let toJson = this.$refs.myMarsmap[0].toGeoJSON();
 | 
				
			||||||
 | 
					            if (toJson.features.length !== 0) {
 | 
				
			||||||
 | 
					              console.log(toJson, "toJson");
 | 
				
			||||||
              // 多边形 首尾相同
 | 
					              // 多边形 首尾相同
 | 
				
			||||||
              geojson.coordinates = toJson.features.map((item) => {
 | 
					              geojson.coordinates = toJson.features.map((item) => {
 | 
				
			||||||
                if (item.properties.type === "polygon") {
 | 
					                if (item.properties.type === "polygon") {
 | 
				
			||||||
                item.geometry.coordinates[0][
 | 
					                  // 确保 coordinates 是有效的多边形坐标(三维数组)
 | 
				
			||||||
                  item.geometry.coordinates[0].length
 | 
					                  if (
 | 
				
			||||||
                ] = item.geometry.coordinates[0][0];
 | 
					                    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") {
 | 
					                } else if (item.properties.type === "pointP") {
 | 
				
			||||||
                console.log(item.geometry.coordinates);
 | 
					                  console.log(item.geometry.coordinates, "112233");
 | 
				
			||||||
                } else if (item.properties.type === "circle") {
 | 
					                } else if (item.properties.type === "circle") {
 | 
				
			||||||
                // eslint-disable-next-line no-undef
 | 
					 | 
				
			||||||
                  const positions = mars3d.PolyUtil.getEllipseOuterPositions({
 | 
					                  const positions = mars3d.PolyUtil.getEllipseOuterPositions({
 | 
				
			||||||
                    position: item.geometry.coordinates,
 | 
					                    position: item.geometry.coordinates,
 | 
				
			||||||
                    radius: item.properties.style.radius
 | 
					                    radius: item.properties.style.radius
 | 
				
			||||||
                  });
 | 
					                  });
 | 
				
			||||||
                  item.geometry.coordinates = [[]];
 | 
					                  item.geometry.coordinates = [[]];
 | 
				
			||||||
                  positions.forEach((el) => {
 | 
					                  positions.forEach((el) => {
 | 
				
			||||||
                  // eslint-disable-next-line no-undef
 | 
					 | 
				
			||||||
                  mars3d.LngLatPoint.fromCartesian(el).toArray(),
 | 
					 | 
				
			||||||
                    item.geometry.coordinates[0].push(
 | 
					                    item.geometry.coordinates[0].push(
 | 
				
			||||||
                      // eslint-disable-next-line no-undef
 | 
					 | 
				
			||||||
                      mars3d.LngLatPoint.fromCartesian(el).toArray()
 | 
					                      mars3d.LngLatPoint.fromCartesian(el).toArray()
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
                  });
 | 
					                  });
 | 
				
			||||||
                  console.log(item.geometry.coordinates);
 | 
					                  console.log(item.geometry.coordinates);
 | 
				
			||||||
 | 
					                  // 为圆添加首坐标到尾部以闭合
 | 
				
			||||||
 | 
					                  if (item.geometry.coordinates[0].length > 0) {
 | 
				
			||||||
                    item.geometry.coordinates[0].push(
 | 
					                    item.geometry.coordinates[0].push(
 | 
				
			||||||
                      item.geometry.coordinates[0][0]
 | 
					                      item.geometry.coordinates[0][0]
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
                // console.log(item.geometry.coordinates);
 | 
					                  }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return item.geometry.coordinates;
 | 
					                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.geoJson = geojson;
 | 
				
			||||||
            this.ruleForm.center = [
 | 
					            this.ruleForm.center = [
 | 
				
			||||||
              this.$refs.myMarsmap[0].lonData,
 | 
					              this.$refs.myMarsmap[0].lonData,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					myMarsmap
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="ditu">
 | 
					  <div class="ditu">
 | 
				
			||||||
    <div id="marsContainer-map" ref="marsMaps" class="mars3d-container"></div>
 | 
					    <div id="marsContainer-map" ref="marsMaps" class="mars3d-container"></div>
 | 
				
			||||||
| 
						 | 
					@ -99,15 +100,14 @@ export default {
 | 
				
			||||||
      deep: true,
 | 
					      deep: true,
 | 
				
			||||||
      immediate: true,
 | 
					      immediate: true,
 | 
				
			||||||
      handler(newVal) {
 | 
					      handler(newVal) {
 | 
				
			||||||
 | 
					        console.log("newVal1111", newVal);
 | 
				
			||||||
        if (newVal) {
 | 
					        if (newVal) {
 | 
				
			||||||
          this.jsonData = JSON.parse(newVal);
 | 
					          this.jsonData = JSON.parse(newVal);
 | 
				
			||||||
          if (this.jsonData) {
 | 
					          if (this.jsonData) {
 | 
				
			||||||
            if (newVal) {
 | 
					 | 
				
			||||||
            this.showRegion(this.jsonData, "geojson");
 | 
					            this.showRegion(this.jsonData, "geojson");
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mapData: {
 | 
					    mapData: {
 | 
				
			||||||
      deep: true,
 | 
					      deep: true,
 | 
				
			||||||
| 
						 | 
					@ -121,9 +121,9 @@ export default {
 | 
				
			||||||
            this.lonData = "";
 | 
					            this.lonData = "";
 | 
				
			||||||
            this.latData = "";
 | 
					            this.latData = "";
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          console.log("mapData发生变化", newVal);
 | 
					 | 
				
			||||||
          if (this.lonData && this.latData) {
 | 
					          if (this.lonData && this.latData) {
 | 
				
			||||||
            if (this.lonData && this.latData) {
 | 
					            if (this.lonData && this.latData) {
 | 
				
			||||||
 | 
					              this.isinputDisabled = true;
 | 
				
			||||||
              this.deviceDrid(this.lonData, this.latData);
 | 
					              this.deviceDrid(this.lonData, this.latData);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
| 
						 | 
					@ -217,6 +217,7 @@ export default {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (this.lonData && this.latData) {
 | 
					      if (this.lonData && this.latData) {
 | 
				
			||||||
        this.deviceDrid(this.lonData, this.latData);
 | 
					        this.deviceDrid(this.lonData, this.latData);
 | 
				
			||||||
 | 
					        this.isinputDisabled = true;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    lineClicks(val) {
 | 
					    lineClicks(val) {
 | 
				
			||||||
| 
						 | 
					@ -334,9 +335,8 @@ export default {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    toGeoJSON() {
 | 
					    toGeoJSON() {
 | 
				
			||||||
      console.log(this.graphicLayer, this.typeOf, "this.graphicLayer");
 | 
					 | 
				
			||||||
      if (this.typeOf === "pointP") {
 | 
					      if (this.typeOf === "pointP") {
 | 
				
			||||||
        return this.graphicLayer.toGeoJSON({ noAlt: true });
 | 
					        // return this.graphicLayer.toGeoJSON({ noAlt: true });
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        this.graphicLayer._graphicList._array.forEach((item) => {
 | 
					        this.graphicLayer._graphicList._array.forEach((item) => {
 | 
				
			||||||
          if (item.type === "billboard") {
 | 
					          if (item.type === "billboard") {
 | 
				
			||||||
| 
						 | 
					@ -347,6 +347,7 @@ export default {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    showRegion(value, type) {
 | 
					    showRegion(value, type) {
 | 
				
			||||||
 | 
					      this.clearDraw();
 | 
				
			||||||
      let geojson = {};
 | 
					      let geojson = {};
 | 
				
			||||||
      if (type === "uploadGeojson") {
 | 
					      if (type === "uploadGeojson") {
 | 
				
			||||||
        if (this.graphicLayer._graphicList.length === 0) {
 | 
					        if (this.graphicLayer._graphicList.length === 0) {
 | 
				
			||||||
| 
						 | 
					@ -387,7 +388,6 @@ export default {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    deviceDrid(lon, lat) {
 | 
					    deviceDrid(lon, lat) {
 | 
				
			||||||
      // this.clearDraw();
 | 
					 | 
				
			||||||
      console.log(this.graphicLayer, "this.graphicLayer");
 | 
					      console.log(this.graphicLayer, "this.graphicLayer");
 | 
				
			||||||
      if (this.graphicLayer) {
 | 
					      if (this.graphicLayer) {
 | 
				
			||||||
        this.graphicLayer.eachGraphic((item) => {
 | 
					        this.graphicLayer.eachGraphic((item) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					PositionDialog
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="position">
 | 
					  <div class="position">
 | 
				
			||||||
    <div class="demo-formName">
 | 
					    <div class="demo-formName">
 | 
				
			||||||
| 
						 | 
					@ -216,9 +217,9 @@ export default {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    // 确定按钮
 | 
					    // 确定按钮
 | 
				
			||||||
    determine(value) {
 | 
					    determine(value) {
 | 
				
			||||||
      let params = {};
 | 
					      let params = { ...value };
 | 
				
			||||||
      params = value;
 | 
					 | 
				
			||||||
      console.log(params, "params");
 | 
					      console.log(params, "params");
 | 
				
			||||||
 | 
					      if (params.geoJson.coordinates.length !== 0) {
 | 
				
			||||||
        params.regionJson = JSON.stringify(params.geoJson);
 | 
					        params.regionJson = JSON.stringify(params.geoJson);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        params.lon = params.center[0];
 | 
					        params.lon = params.center[0];
 | 
				
			||||||
| 
						 | 
					@ -234,6 +235,8 @@ export default {
 | 
				
			||||||
                if (res.code === 0) {
 | 
					                if (res.code === 0) {
 | 
				
			||||||
                  this.$message.success("新增成功");
 | 
					                  this.$message.success("新增成功");
 | 
				
			||||||
                  this.headdenForm({}, "search");
 | 
					                  this.headdenForm({}, "search");
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                  this.$message.error(res.msg);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              })
 | 
					              })
 | 
				
			||||||
              .catch((err) => {
 | 
					              .catch((err) => {
 | 
				
			||||||
| 
						 | 
					@ -244,6 +247,8 @@ export default {
 | 
				
			||||||
              if (res.code === 0) {
 | 
					              if (res.code === 0) {
 | 
				
			||||||
                this.$message.success("编辑成功");
 | 
					                this.$message.success("编辑成功");
 | 
				
			||||||
                this.headdenForm({}, "search");
 | 
					                this.headdenForm({}, "search");
 | 
				
			||||||
 | 
					              } else {
 | 
				
			||||||
 | 
					                this.$message.error(res.msg);
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
| 
						 | 
					@ -251,6 +256,9 @@ export default {
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          this.$message.error("请选择地图上的经纬度");
 | 
					          this.$message.error("请选择地图上的经纬度");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.$message.error("请绘制地图上的防区");
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    // 新增 搜索
 | 
					    // 新增 搜索
 | 
				
			||||||
    headdenForm(value, type) {
 | 
					    headdenForm(value, type) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue