Browse Source

偏移矫正

Bella 2 năm trước cách đây
mục cha
commit
1783cb828a

+ 2 - 0
public/static/config/config.js

@@ -5,6 +5,8 @@
  * version 0.0.1
  */
 var systemConfig = {
+  // 经度偏移矫正值 -- WGS84转上海2000
+  lonCorrectParams:0.1915,
   assetsUrl: "http://localhost:2013",
   mapViewer: {
     center: [31.105589678244445, 121.72894516017521],

+ 168 - 104
src/components/map/MapHolder.vue

@@ -24,7 +24,7 @@ export default {
     CaseAuditPopup,
     NormalAttrPopup,
     LabelCasePopup,
-    BasemapChange
+    BasemapChange,
   },
   data() {
     return {
@@ -46,7 +46,7 @@ export default {
       currentLabelHtml: null,
       tableObj: {},
       // 疑点审计的保存后的疑点状态集合
-      caseStatusMap: new Map()
+      caseStatusMap: new Map(),
     };
   },
   created() {},
@@ -77,7 +77,7 @@ export default {
       deleteSinglePolygon: this.deleteSinglePolygon,
       deleteGroupFromMap: this.deleteGroupFromMap,
       drawGeometry: this.drawGeometry,
-      deleteGeometry: this.deleteGeometry
+      deleteGeometry: this.deleteGeometry,
     });
   },
   beforeDestroyed() {
@@ -98,7 +98,7 @@ export default {
     // 监听当前菜单
     getCurrentMenu() {
       return this.$store.state.navSelect;
-    }
+    },
   },
   watch: {
     getLabelCaseBtnStatus(val) {
@@ -141,9 +141,9 @@ export default {
         this.$nextTick(() => {
           this.getJSonData();
         });
-      }
+      },
       // immediate: true
-    }
+    },
   },
   methods: {
     // 开始标记疑点事件
@@ -154,7 +154,7 @@ export default {
     stopLabelCase() {
       if (map2DViewer.measureTool) {
         map2DViewer.setDrawTool({
-          action: "remove"
+          action: "remove",
         });
       }
     },
@@ -173,16 +173,19 @@ export default {
       let geoProperties = JSON.parse(geojsonData).properties;
       // 搜索geojson数据中的固定字段 -- 镇域名称,面积,土地类型,图斑编号
       this.$refs.normalRef.tableObj["面积"] = geoProperties["面积"] || "--";
-      this.$refs.normalRef.tableObj["镇域名称"] = geoProperties["镇域名称"] || "--";
-      this.$refs.normalRef.tableObj["土地类型"] = geoProperties["土地类型"] || "--";
-      this.$refs.normalRef.tableObj["图斑编号"] = geoProperties["图斑编号"] || "--";
+      this.$refs.normalRef.tableObj["镇域名称"] =
+        geoProperties["镇域名称"] || "--";
+      this.$refs.normalRef.tableObj["土地类型"] =
+        geoProperties["土地类型"] || "--";
+      this.$refs.normalRef.tableObj["图斑编号"] =
+        geoProperties["图斑编号"] || "--";
       let currentInnerHtml = this.$refs.normalRef.$el.innerHTML;
       // 需要重新绘制的属性obj
       let targetObj = {
         镇域名称: geoProperties["镇域名称"] || "--",
         面积: geoProperties["面积"] || "--",
         土地类型: geoProperties["土地类型"] || "--",
-        图斑编号: geoProperties["图斑编号"] || "--"
+        图斑编号: geoProperties["图斑编号"] || "--",
       };
 
       if (currentInnerHtml) {
@@ -198,21 +201,27 @@ export default {
             if ($(`#${str}_id a`)) {
               // 属性框内容
               if ($(".center-table-item-normal")) {
-                $(".center-table-item-normal .leftcell").each((index, domEle) => {
-                  $(".center-table-item-normal .leftcell").eq(index).text(Object.keys(targetObj)[index]);
-                  $(".center-table-item-normal .rightcell").eq(index).text(Object.values(targetObj)[index]);
-                });
+                $(".center-table-item-normal .leftcell").each(
+                  (index, domEle) => {
+                    $(".center-table-item-normal .leftcell")
+                      .eq(index)
+                      .text(Object.keys(targetObj)[index]);
+                    $(".center-table-item-normal .rightcell")
+                      .eq(index)
+                      .text(Object.values(targetObj)[index]);
+                  }
+                );
               }
 
               $(`#${str}_id a`)
                 .eq(0)
-                .click(e => {
+                .click((e) => {
                   this.$store.state.lawPopupShow = true;
                   this.$store.state.lawSourceType = sourceType;
                 });
               $(`#${str}_id a`)
                 .eq(1)
-                .click(e => {
+                .click((e) => {
                   // 触发综合分析右侧面板点击事件
                   this.$bus.$emit("viewDetailsPopup", geojsonData);
                 });
@@ -225,7 +234,7 @@ export default {
               $(`#${str}_id a`).remove();
             }
           });
-          console.log("呈现我的模型的几何数据");
+          // console.log("呈现我的模型的几何数据");
         }
 
         return div;
@@ -243,8 +252,10 @@ export default {
       let geoProperties = JSON.parse(geojsonData).properties;
       // 搜索geojson数据中的固定字段 -- 镇域名称,面积,土地类型,图斑编号
       this.$refs.auditRef.tableObj["面积"] = geoProperties["面积"] || "--";
-      this.$refs.auditRef.tableObj["镇域名称"] = geoProperties["镇域名称"] || "--";
-      this.$refs.auditRef.tableObj["图层构成"] = geoProperties["图层构成"] || "--";
+      this.$refs.auditRef.tableObj["镇域名称"] =
+        geoProperties["镇域名称"] || "--";
+      this.$refs.auditRef.tableObj["图层构成"] =
+        geoProperties["图层构成"] || "--";
       this.$refs.auditRef.tableObj["性质"] = geoProperties["性质"] || "--";
 
       // 需要重新绘制的属性obj
@@ -252,7 +263,7 @@ export default {
         镇域名称: geoProperties["镇域名称"] || "--",
         面积: geoProperties["面积"] || "--",
         图层构成: geoProperties["图层构成"] || "--",
-        性质: geoProperties["性质"] || "--"
+        性质: geoProperties["性质"] || "--",
       };
       if (this.currentHtml) {
         let div = document.createElement("div");
@@ -264,22 +275,32 @@ export default {
           // 属性框内容
           if ($(".center-table-item-normal")) {
             $(".center-table-item-normal .leftcell").each((index, domEle) => {
-              $(".center-table-item-normal .leftcell").eq(index).text(Object.keys(targetObj)[index]);
-              $(".center-table-item-normal .rightcell").eq(index).text(Object.values(targetObj)[index]);
+              $(".center-table-item-normal .leftcell")
+                .eq(index)
+                .text(Object.keys(targetObj)[index]);
+              $(".center-table-item-normal .rightcell")
+                .eq(index)
+                .text(Object.values(targetObj)[index]);
             });
           }
 
           if ($(".center-table-item-special")) {
             $(".center-table-item-special .leftcell").each((index, domEle) => {
-              $(".center-table-item-speciall .leftcell").eq(index).text(Object.keys(targetObj)[index]);
-              $(".center-table-item-special .rightcell").eq(index).text(Object.values(targetObj)[index]);
+              $(".center-table-item-speciall .leftcell")
+                .eq(index)
+                .text(Object.keys(targetObj)[index]);
+              $(".center-table-item-special .rightcell")
+                .eq(index)
+                .text(Object.values(targetObj)[index]);
             });
           }
 
           // 下拉框内容
           if ($(`#${str}_id .center-table-item-special select`)) {
             if (this.caseStatusMap.has(str)) {
-              $(`#${str}_id .center-table-item-special select`).val(this.caseStatusMap.get(str));
+              $(`#${str}_id .center-table-item-special select`).val(
+                this.caseStatusMap.get(str)
+              );
             }
           }
 
@@ -287,13 +308,13 @@ export default {
           if ($(`#${str}_id a`)) {
             $(`#${str}_id a`)
               .eq(0)
-              .click(e => {
+              .click((e) => {
                 this.$store.state.lawPopupShow = true;
                 this.$store.state.lawSourceType = sourceType;
               });
             $(`#${str}_id a`)
               .eq(1)
-              .click(e => {
+              .click((e) => {
                 // 触发综合分析右侧面板点击事件
 
                 this.$bus.$emit("viewDetailsPopup", geojsonData);
@@ -301,7 +322,7 @@ export default {
           }
           // input添加点击事件
           if ($(`#${str}_id input`)[1]) {
-            $(`#${str}_id input`).click(e => {
+            $(`#${str}_id input`).click((e) => {
               switch (e.target.defaultValue) {
                 case "取消":
                   this.cancelBtnEvent();
@@ -324,8 +345,8 @@ export default {
      * @geoType -- 几何体类型
      */
     createLabelDiv(str, coord, data, geoType) {
-      console.log(str, coord, data, geoType, "createLabelDiv");
-      console.log(str, "label - str");
+      // console.log(str, coord, data, geoType, "createLabelDiv");
+      // console.log(str, "label - str");
       this.currentLabelHtml = this.$refs.labelRef.$el.innerHTML;
       if (this.currentLabelHtml) {
         let div = document.createElement("div");
@@ -337,7 +358,7 @@ export default {
           console.log($(`#${str}_id textarea`).val(), "textarea");
           $(`#${str}_id`).css("height", "100%");
 
-          $(`#${str}_id input`).click(e => {
+          $(`#${str}_id input`).click((e) => {
             console.log(e.target.defaultValue);
             switch (e.target.defaultValue) {
               case "取消":
@@ -366,20 +387,22 @@ export default {
         // 修改人员名称
         c_editor_name: localStorage.getItem("USER_NAME"),
         // 修改人员ID
-        c_editorid: localStorage.getItem("USER_ID")
+        c_editorid: localStorage.getItem("USER_ID"),
       };
       let modifyParams = new FormData();
       modifyParams = {
         columnId: 510,
         modelId: 118,
-        content: JSON.stringify(obj)
+        content: JSON.stringify(obj),
       };
-      this.$Post(this.urlsCollection.updateContent, modifyParams).then(res => {
-        if (res.code === 200) {
-          this.$message.success("数据修改成功");
-          map2DViewer.map.closePopup();
+      this.$Post(this.urlsCollection.updateContent, modifyParams).then(
+        (res) => {
+          if (res.code === 200) {
+            this.$message.success("数据修改成功");
+            map2DViewer.map.closePopup();
+          }
         }
-      });
+      );
     },
     cancelBtnEvent() {
       map2DViewer.map.closePopup();
@@ -404,7 +427,13 @@ export default {
         } else {
           geoName = $(`#${str}_id input`).eq(0).val();
           let coordinates = [data.points];
-          let geometry = publicFun.generateGeoJSON(title, des, geoType, coordinates, geoName);
+          let geometry = publicFun.generateGeoJSON(
+            title,
+            des,
+            geoType,
+            coordinates,
+            geoName
+          );
           let params = new FormData();
           let newGeojson = JSON.stringify(geometry);
           myLabelNameMap.set(geoName, newGeojson);
@@ -412,11 +441,11 @@ export default {
             geojson: newGeojson,
             type: geoType,
             userId: Number(localStorage.getItem("USER_ID")),
-            sourceId: 0
+            sourceId: 0,
           };
 
           this.$Post(this.urlsCollection.addConllection, params).then(
-            res => {
+            (res) => {
               if (res.code == 200) {
                 // 标记成功后删除保存的原有名称
                 myLabelNameMap.delete(geoName);
@@ -426,33 +455,36 @@ export default {
                 paramData = {
                   userId: Number(localStorage.getItem("USER_ID")),
                   sourceId: 0,
-                  pageSize: 10
+                  pageSize: 10,
                 };
                 // 暂存map中刚刚保存的数据
-                this.$Post(this.urlsCollection.selectByUser, paramData).then(userRes => {
-                  if (userRes.code === 200) {
-                    if (userRes.content.length > 0) {
-                      this.$store.state.myLabelPointsArr = [];
-                      this.$store.state.myLabelPointsArr = userRes.content.map(v => {
-                        if (JSON.stringify(geometry) === v.geojson) {
-                          sessionStorage.setItem("myLabelPointsId", v.id);
-                        }
-                        return {
-                          id: v.id,
-                          geojson: v.geojson,
-                          type: v.type
-                        };
-                      });
-                      // 判断刚刚暂存的数据,并调用小眼睛的方法
+                this.$Post(this.urlsCollection.selectByUser, paramData).then(
+                  (userRes) => {
+                    if (userRes.code === 200) {
+                      if (userRes.content.length > 0) {
+                        this.$store.state.myLabelPointsArr = [];
+                        this.$store.state.myLabelPointsArr =
+                          userRes.content.map((v) => {
+                            if (JSON.stringify(geometry) === v.geojson) {
+                              sessionStorage.setItem("myLabelPointsId", v.id);
+                            }
+                            return {
+                              id: v.id,
+                              geojson: v.geojson,
+                              type: v.type,
+                            };
+                          });
+                        // 判断刚刚暂存的数据,并调用小眼睛的方法
+                      }
                     }
+                    // 更新时调用一次搜索接口
                   }
-                  // 更新时调用一次搜索接口
-                });
+                );
               }
               // 保存后需要删除地图上的标记
               this.reStartLabelCase();
             },
-            error => {
+            (error) => {
               console.log("标记疑点保存失败!", error);
               this.reStartLabelCase();
             }
@@ -466,7 +498,9 @@ export default {
         map2DViewer.jlMap = L.tileLayer(
           "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d"
         ).addTo(map2DViewer.map);
-        map2DViewer.jlControl = L.control.sideBySide(map2DViewer.map, map2DViewer.jlMap).addTo(map2DViewer.map);
+        map2DViewer.jlControl = L.control
+          .sideBySide(map2DViewer.map, map2DViewer.jlMap)
+          .addTo(map2DViewer.map);
       } else if (map2DViewer.map.hasLayer(map2DViewer.jlMap)) {
         map2DViewer.map.removeControl(map2DViewer.jlControl);
         map2DViewer.map.removeLayer(map2DViewer.jlMap);
@@ -489,7 +523,13 @@ export default {
       // 每次点击按钮后重绘弹窗
       if (this.currentHtml && this.currentCid) {
         setTimeout(() => {
-          this.popup.setContent(this.createAuditDiv(this.currentCid, this.currentProperties, this.currentSourceType));
+          this.popup.setContent(
+            this.createAuditDiv(
+              this.currentCid,
+              this.currentProperties,
+              this.currentSourceType
+            )
+          );
           // .openOn(map2DViewer.map);
         }, 300);
       }
@@ -498,7 +538,7 @@ export default {
     initDraw() {
       if (!map2DViewer.measureTool) {
         // 引入疑点标记绘制方法
-        map2DViewer.drawToolFire = data => {
+        map2DViewer.drawToolFire = (data) => {
           // 纬经度
           if (data && data.points.length >= 1) {
             let geoType = null;
@@ -537,7 +577,7 @@ export default {
           color: "red",
           font_size: "14px",
           closeButton: true,
-          iconUrl: "../../static/plugins/draw-plugin/images/marker-icon.png"
+          iconUrl: "../../static/plugins/draw-plugin/images/marker-icon.png",
         });
       }
     },
@@ -548,11 +588,13 @@ export default {
         "+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=0 +y_0=-3457147.81 +ellps=krass +units=m +no_defs",
         {
           resolutions: [
-            132.2919312505292, 52.91677250021167, 26.458386250105836, 13.229193125052918, 5.291677250021167, 2.6458386250105836,
-            1.3229193125052918, 0.5291677250021167, 0.26458386250105836, 0.13229193125052918
+            132.2919312505292, 52.91677250021167, 26.458386250105836,
+            13.229193125052918, 5.291677250021167, 2.6458386250105836,
+            1.3229193125052918, 0.5291677250021167, 0.26458386250105836,
+            0.13229193125052918,
           ],
           origin: [-66000, 75000],
-          bounds: L.bounds([-65000, -76000], [75000, 72000])
+          bounds: L.bounds([-65000, -76000], [75000, 72000]),
         }
       );
 
@@ -562,7 +604,7 @@ export default {
         minZoom: 1,
         maxZoom: 6,
         attributionControl: false,
-        zoomControl: false
+        zoomControl: false,
         // preferCanvas: true,
       }).setView(systemConfig.mapViewer.center, systemConfig.mapViewer.zoom);
 
@@ -578,7 +620,7 @@ export default {
           url: "http://aimap.pudong.sh:5236/zjmap/reproduction-service/maps/rest/services/sat-2019s4/proxy?AccessKey=lUaEMxqqhZKLSImGuP/Ergx47orYVyIqHVgxfyGpIurKAy9kdq5uU1cWuTuIXeOM",
           // http://aimap.pudong.sh:5236/zjmap/reproduction-service/maps/rest/services/sat-2019s4/proxy?AccessKey=lUaEMxqqhZKLSImGuP/Ergx47orYVyIqHVgxfyGpIurKAy9kdq5uU1cWuTuIXeOM
           // url: "http://aimap.pudong.sh:5236/maps/rest/services/basemap-shanghai-gem-blue-sh2000/mapserver",
-          tileSize: 512
+          tileSize: 512,
           // systemConfig.blueBlackMap,
         })
         .addTo(map2DViewer.map);
@@ -597,13 +639,19 @@ export default {
         map2DViewer.groups["浦东新区_polygon"].remove();
       }
       // 请求并渲染新的区域图层
-      get("./static/json/simplified_pdgeojson.json", "").then(geoJson => {
+      get("./static/json/simplified_pdgeojson.json", "").then((geoJson) => {
         // 存放所有的面数据
         map2DViewer.groups["浦东新区_polygon"] = L.featureGroup();
         map2DViewer.groups["浦东新区_label"] = L.featureGroup();
         map2DViewer.groups["浦东新区_polygon"].addTo(map2DViewer.map);
         map2DViewer.groups["浦东新区_label"].addTo(map2DViewer.map);
-        geoJson.features.map(feature => {
+        geoJson.features.map((feature) => {
+          let correctCordArr = JSON.parse(
+            JSON.stringify(feature.geometry.coordinates)
+          );
+          let newCorrectCoordArr = publicFun.latLngsCorrection(correctCordArr);
+          feature.geometry.coordinates = newCorrectCoordArr;
+
           // if (
           //   this.town.indexOf(feature.properties.NAME.replace("镇", "")) > -1
           // ) {
@@ -618,12 +666,15 @@ export default {
     w84Proj4ToShanghai(val) {
       // 参数1:随意定义的坐标系名称,格式“EPSG:xxxxx”
       // 参数2:prj文件里的内容
-      this.$proj4.defs("EPSG:0986","+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=0 +y_0=-3457147.81 +ellps=GRS80 +units=m +no_defs +type=crs");
-        // "+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=0 +y_0=-3457147.81 +ellps=krass +units=m +no_defs",
+      this.$proj4.defs(
+        "EPSG:0986",
+        "+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=0 +y_0=-3457147.81 +ellps=GRS80 +units=m +no_defs +type=crs"
+      );
+      // "+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=0 +y_0=-3457147.81 +ellps=krass +units=m +no_defs",
       // 从"EPSG:0986"转成"EPSG:4326"
       // coordinate 类型Array  例:[116, 39]
       let pro = `PROJCS[\"shanghaicity\",GEOGCS[\"GCS_Beijing_1954\",DATUM[\"D_Beijing_1954\",SPHEROID[\"Krasovsky_1940\",6378245.0,298.3]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",-3457147.81],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",121.2751921],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]`;
-      return this.$proj4( "EPSG:0986", "EPSG:4326",val);
+      return this.$proj4("EPSG:0986", "EPSG:4326", val);
     },
     // 可视化单一的镇域面
     getSingleJsonData(name) {},
@@ -639,7 +690,10 @@ export default {
         this.getJSonDataToStreet("", "");
         // 切换到首页时需定位到当前图层
         if (this.$store.state.homeSpecialTown === "全部") {
-          this.setView(townLocationMap.get(this.$store.state.homeSpecialTown), 10);
+          this.setView(
+            townLocationMap.get(this.$store.state.homeSpecialTown),
+            10
+          );
         } else {
           let polygon = townPolygonMap.get(this.$store.state.homeSpecialTown);
           map2DViewer.map.fitBounds(polygon.getBounds());
@@ -654,8 +708,8 @@ export default {
       }
     },
     setView: function (coord, zoom) {
-      // console.log(coord, "位置");
-      let center = L.latLng(coord[0]-0.1915, coord[1]);
+      coord = publicFun.latLngsCorrection(coord);
+      let center = L.latLng(coord[0], coord[1]);
       map2DViewer.map.setView(center, zoom);
     },
     renderPolygon: function (feature) {
@@ -671,14 +725,16 @@ export default {
         weight: 3,
         fillColor: this.getColor(name),
         opacity: 1,
-        fillOpacity: 0.4
+        fillOpacity: 0.4,
       }).addTo(map2DViewer.groups["浦东新区_polygon"]);
 
       center = JSON.parse(JSON.stringify(center)).geometry.coordinates;
-      center[0] -= 0.1915;
+      // center = publicFun.latLngsCorrection(center)
+      // 坐标偏移矫正
+      // center[0] -= 0.1915;
       // center = coordinate.wgs84_to_shcj(center[0],center[1]);
       // center = this.w84Proj4ToShanghai(center);
-      console.log("center",center);
+      // console.log("center",center);
 
       center.reverse();
       // 坐标
@@ -688,31 +744,31 @@ export default {
         radius: 10,
         weight: 1,
         fillOpacity: 0,
-        color: "#e6d273"
+        color: "#e6d273",
       });
       wmarker.bindLabel(feature.properties.NAME, {
         noHide: true,
         clickable: true,
-        offset: [-25, 10]
+        offset: [-25, 10],
       });
       wmarker.addTo(map2DViewer.groups["浦东新区_label"]);
       let circle1 = L.circleMarker(center, {
         radius: 8,
         weight: 1,
         fillOpacity: 0,
-        color: "#e6d273"
+        color: "#e6d273",
       }).addTo(map2DViewer.groups["浦东新区_polygon"]);
       let circle2 = L.circleMarker(center, {
         radius: 5,
         weight: 1,
         fillOpacity: 1,
-        color: "#e6d273"
+        color: "#e6d273",
       }).addTo(map2DViewer.groups["浦东新区_polygon"]);
     },
     latLngsToReverse: function (latlngsAry) {
       var tempLatlngsAry = JSON.parse(JSON.stringify(latlngsAry));
       if (typeof tempLatlngsAry[0] != "object") {
-        tempLatlngsAry[0] -= 0.1915;
+        // tempLatlngsAry[0] -= 0.1915;
         return tempLatlngsAry.reverse();
       } else {
         for (var i = 0, l = tempLatlngsAry.length; i < l; i++) {
@@ -744,30 +800,33 @@ export default {
     addSinglePolygon(geometry, cid, color, uniqueId, mainType, sourceType) {
       let uniqueIdList = [];
       if (this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId]) {
-        uniqueIdList = this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId];
+        uniqueIdList =
+          this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId];
       }
 
       let singlePolygonItem = {
         uniqueId: uniqueId,
         geometry: geometry,
-        cid: cid
+        cid: cid,
       };
       uniqueIdList.push(singlePolygonItem);
-      this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId] = uniqueIdList;
+      this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId] =
+        uniqueIdList;
       // 当前数据坐标系为WGS84
       let targetGeometry = JSON.parse(geometry).geometry;
       // 预设模型与所有图层层级不同
       let coord = targetGeometry.coordinates;
-      let coordinates = publicFun.latLngsToReverse(coord);
+      let correctCoord = publicFun.latLngsCorrection(coord);
+      let coordinates = publicFun.latLngsToReverse(correctCoord);
       let polygon = L.polygon(coordinates, {
         color: color,
         weight: 3,
         fillColor: color,
         opacity: 1,
-        fillOpacity: 0.4
+        fillOpacity: 0.4,
       }).addTo(map2DViewer.analysisGroups[uniqueId]);
 
-      polygon.on("click", e => {
+      polygon.on("click", (e) => {
         let geojsonData = geometry;
         // 所有图层下的疑点图层 -- 常规展示
         if (mainType === "所有图层") {
@@ -803,7 +862,7 @@ export default {
     },
     // 综合分析 - 图层绘制面
     addPolygonLayer(data, cid, color) {
-      data.map(feature => {
+      data.map((feature) => {
         let polygonData = JSON.parse(JSON.stringify(feature));
         let coordinates = polygonData.geometry.coordinates[0];
         let infos = polygonData.properties;
@@ -812,16 +871,18 @@ export default {
           weight: 3,
           fillColor: color,
           opacity: 1,
-          fillOpacity: 0.4
+          fillOpacity: 0.4,
         }).addTo(map2DViewer.map);
         map2DViewer.polygons[`${cid}_layer`].push(polygon);
         polygon.infos = infos;
-        polygon.on("click", e => {
+        polygon.on("click", (e) => {
           // console.log(e, "polygon");
           this.auditPopupShow = true;
           // console.log(e.latlng, "获取当前弹窗坐标111");
 
-          this.popup = L.popup({ maxWidth: 700, maxHeight: 600 }).setLatLng(e.latlng).setContent(this.createAuditDiv(cid));
+          this.popup = L.popup({ maxWidth: 700, maxHeight: 600 })
+            .setLatLng(e.latlng)
+            .setContent(this.createAuditDiv(cid));
           // .openOn(map2DViewer.map);
           this.auditPopupShow = false;
           this.popup.openOn(map2DViewer.map);
@@ -841,15 +902,16 @@ export default {
     //综合分析 - 标记疑点 - 删除面
     deletePolygonLayer(layer) {
       console.log(layer, "layer");
-      map2DViewer.polygons[layer].forEach(polygon => {
+      map2DViewer.polygons[layer].forEach((polygon) => {
         map2DViewer.map.removeLayer(polygon);
       });
     },
 
     drawPoints(data) {
       if (!map2DViewer.myLabels[`label_${data.id}`]) {
+        data.coord = publicFun.latLngsCorrection(data.coord)
         let point = L.marker(data.coord, {
-          opacity: 1
+          opacity: 1,
         }).addTo(map2DViewer.groups["我的标记图层组"]);
         map2DViewer.myLabels[`label_${data.id}`] = point;
       }
@@ -857,12 +919,13 @@ export default {
     drawLine(data, color) {
       if (!map2DViewer.myLabels[`label_${data.id}`]) {
         let coordinates = JSON.parse(data.geojson).geometry.coordinates[0];
+        coordinates = publicFun.latLngsCorrection(coordinates)
         let polyline = L.polyline(coordinates, {
           color: color,
           weight: 3,
           fillOpacity: color,
           opacity: 1,
-          fillOpacity: 0.4
+          fillOpacity: 0.4,
         }).addTo(map2DViewer.groups["我的标记图层组"]);
         // zoom the map to the polyline
         map2DViewer.myLabels[`label_${data.id}`] = polyline;
@@ -871,12 +934,13 @@ export default {
     drawPolygon(data, color) {
       if (!map2DViewer.myLabels[`label_${data.id}`]) {
         let coordinates = JSON.parse(data.geojson).geometry.coordinates[0];
+        coordinates = publicFun.latLngsCorrection(coordinates)
         let polygon = L.polygon(coordinates, {
           color: color,
           weight: 3,
           fillOpacity: color,
           opacity: 1,
-          fillOpacity: 0.4
+          fillOpacity: 0.4,
         }).addTo(map2DViewer.groups["我的标记图层组"]);
 
         map2DViewer.myLabels[`label_${data.id}`] = polygon;
@@ -886,7 +950,7 @@ export default {
     drawCircle(data, color) {
       if (!map2DViewer.myLabels[`label_${data.id}`]) {
         let coordinates = JSON.parse(data.geojson).geometry.coordinates[0];
-
+        coordinates = publicFun.latLngsCorrection(coordinates)
         if ((coordinates.length = 2)) {
           let from = turf.point(coordinates[0].reverse());
           let to = turf.point(coordinates[1].reverse());
@@ -899,7 +963,7 @@ export default {
             fillOpacity: color,
             opacity: 1,
             fillOpacity: 0.4,
-            radius: Number(distance)
+            radius: Number(distance),
           }).addTo(map2DViewer.groups["我的标记图层组"]);
           map2DViewer.myLabels[`label_${data.id}`] = circle;
         }
@@ -930,8 +994,8 @@ export default {
       if (geometry) {
         geometry.removeFrom(map2DViewer.map);
       }
-    }
-  }
+    },
+  },
 };
 </script>
 <style lang="less" scoped>

+ 25 - 0
src/utils/publicFunction.js

@@ -238,6 +238,30 @@ let group = (arr, field) => {
   return map;
 };
 
+/**
+ * 多维数组偏移调整
+ */
+let latLngsCorrection = (latlngsAry)=>{
+   // 深拷贝
+   var tempLatlngsAry = JSON.parse(JSON.stringify(latlngsAry));
+   if (typeof tempLatlngsAry[0] === "number") {
+     if (tempLatlngsAry.length < 3 && tempLatlngsAry.length > 0) {
+      // systemConfig.lonCorrectParams -- 经度偏移校正值
+      tempLatlngsAry[0]-= systemConfig.lonCorrectParams
+       return tempLatlngsAry;
+     }
+     if (tempLatlngsAry.length === 3) {
+      tempLatlngsAry[0]-= systemConfig.lonCorrectParams
+       return tempLatlngsAry;
+     }
+   } else {
+     for (var i = 0, l = tempLatlngsAry.length; i < l; i++) {
+       tempLatlngsAry[i] = latLngsCorrection(tempLatlngsAry[i]);
+     }
+   }
+   return tempLatlngsAry;
+}
+
 /**
  * 多维数组转置
  */
@@ -269,6 +293,7 @@ export default {
   generateGeoJSON,
   standardGeojson,
   convertTree,
+  latLngsCorrection,
   latLngsToReverse,
   getRGBColor,
 };

+ 92 - 55
src/views/HomeView.vue

@@ -23,7 +23,7 @@
           menuIndex: '2',
           subMenuIndex: '5',
           legendIcon: legendIcon,
-          legendTitle: legendTitle
+          legendTitle: legendTitle,
         }"
       />
       <div class="select-title">所属街道</div>
@@ -37,7 +37,10 @@
     </div>
 
     <!-- 综合分析 -->
-    <ComprehensiveAnalysis id="ComprehensiveContainer" v-show="$ifMenu('3', '')" />
+    <ComprehensiveAnalysis
+      id="ComprehensiveContainer"
+      v-show="$ifMenu('3', '')"
+    />
 
     <!-- 法律法规 -->
     <LawView id="LawContainer" v-if="$ifMenu('5', '1')" />
@@ -55,7 +58,8 @@
     </div>
     <!-- 左侧菜单列(较宽,两列) -- 疑点筛查 -->
     <div id="leftMenusW" v-for="(item, index) in menus.leftW" :key="index">
-      <MenuCard :menuData="item2" v-for="item2 in item" :key="item2.title"> </MenuCard>
+      <MenuCard :menuData="item2" v-for="item2 in item" :key="item2.title">
+      </MenuCard>
     </div>
     <!-- 中部菜单列 -->
     <div id="mainMenus">
@@ -101,17 +105,35 @@
           boxHeight: '180',
           menuIndex: '1',
           legendIcon: legendIcon,
-          legendTitle: legendTitle
+          legendTitle: legendTitle,
         }"
       />
     </div>
     <!-- 首页右侧菜单列 -->
-    <div class="rightMenus" v-for="(item, index) in menus.right" :key="'rightBox' + index">
-      <MenuCard :menuData="item2" v-for="(item2, index2) in item" :key="'right' + index2"> </MenuCard>
+    <div
+      class="rightMenus"
+      v-for="(item, index) in menus.right"
+      :key="'rightBox' + index"
+    >
+      <MenuCard
+        :menuData="item2"
+        v-for="(item2, index2) in item"
+        :key="'right' + index2"
+      >
+      </MenuCard>
     </div>
     <!-- 首页右侧菜单列 -->
-    <div class="rightMenusW" v-for="(item, index) in menus.rightW" :key="'rightBoxW' + index">
-      <MenuCard :menuData="item2" v-for="(item2, index2) in item" :key="'rightW' + index2"> </MenuCard>
+    <div
+      class="rightMenusW"
+      v-for="(item, index) in menus.rightW"
+      :key="'rightBoxW' + index"
+    >
+      <MenuCard
+        :menuData="item2"
+        v-for="(item2, index2) in item"
+        :key="'rightW' + index2"
+      >
+      </MenuCard>
     </div>
   </div>
 </template>
@@ -158,7 +180,7 @@ export default {
     WholeProcessManagement,
     FrequencyView,
     LawView,
-    IndexSystem
+    IndexSystem,
   },
   data() {
     return {
@@ -167,7 +189,7 @@ export default {
         type: "lr",
         title: "林地面积",
         value: 654,
-        unit: "公顷"
+        unit: "公顷",
       },
       testTitle: "土地资源",
       activeIndex: 1,
@@ -176,38 +198,38 @@ export default {
         left: [],
         leftW: [],
         main: [],
-        right: []
+        right: [],
       },
       // 首页饼图相关
       buttonData: ["A", "B", "C"],
       legendTitle: [
         {
           name: "A类",
-          info: "耕地林地总和占镇域面积约 45%以上,或超过3000公顷"
+          info: "耕地林地总和占镇域面积约 45%以上,或超过3000公顷",
         },
         {
           name: "B类",
-          info: "有一定的自然资源资产(耕地林地总和 900-3000公项)"
+          info: "有一定的自然资源资产(耕地林地总和 900-3000公项)",
         },
         {
           name: "C类",
-          info: "自然资源资产较少(耕地林地总和低于 900公项)"
-        }
+          info: "自然资源资产较少(耕地林地总和低于 900公项)",
+        },
       ],
       // legendData: ["#E565FF", "#0055FF", "#00FFD5"],
       legendIcon: [
         {
           background: "#E565FF",
-          border: "none"
+          border: "none",
         },
         {
           background: "#0055FF",
-          border: "none"
+          border: "none",
         },
         {
           background: "#00FFD5",
-          border: "none"
-        }
+          border: "none",
+        },
       ],
       btnChecked: "A",
       soil: [],
@@ -218,19 +240,19 @@ export default {
         soil: [],
         other: [],
         forestry: [],
-        categoryData: []
+        categoryData: [],
       },
       BData: {
         soil: [],
         other: [],
         forestry: [],
-        categoryData: []
+        categoryData: [],
       },
       CData: {
         soil: [],
         other: [],
         forestry: [],
-        categoryData: []
+        categoryData: [],
       },
       streetSelectVal: "全部",
       streetOptions: [],
@@ -239,12 +261,12 @@ export default {
         { name: "土地资源问题", num: 67 },
         { name: "水资源问题", num: 37 },
         { name: "林地资源问题", num: 60 },
-        { name: "生态资源问题", num: 55 }
+        { name: "生态资源问题", num: 55 },
       ],
       // 综合分析
       analysis: {
-        searchInput: ""
-      }
+        searchInput: "",
+      },
     };
   },
   mounted() {
@@ -256,12 +278,12 @@ export default {
       let params = new FormData();
       params = {
         type: type,
-        cName: cName
+        cName: cName,
       };
-      this.$Post(this.urlsCollection.selectByCNameAType, params).then(res => {
+      this.$Post(this.urlsCollection.selectByCNameAType, params).then((res) => {
         if (res.code === 200 && res.content.length > 0) {
           this.classTextToIndex[keyName] = new Map();
-          res.content.forEach(v => {
+          res.content.forEach((v) => {
             this.classTextToIndex[keyName].set(v.index + "", v.name);
           });
         }
@@ -313,12 +335,12 @@ export default {
       params.append("type", type);
       params.append("cName", cName);
       this.$Post(this.urlsCollection.selectByCNameAType, params).then(
-        res => {
+        (res) => {
           if (res.code === 200 && res.content.length > 0) {
             this.$store.state.selectSelectDataMap[keyName] = res.content;
           }
         },
-        error => {
+        (error) => {
           this.$message.error(error);
           console.log(error);
         }
@@ -352,10 +374,10 @@ export default {
         columnId: 30,
         states: "0,1,2,3",
         pageSize: 30,
-        page: 0
+        page: 0,
       };
       this.$Post(this.urlsCollection.selectContentList, params)
-        .then(res => {
+        .then((res) => {
           if (res.code === 200 && res.content.data.length > 0) {
             // console.log(res.content.data, "getSourcesData接口获取成功");
             this.soil = [];
@@ -365,32 +387,38 @@ export default {
             let ADataArr = [];
             let BDataArr = [];
             let CDataArr = [];
-            data.map(v => {
+            data.map((v) => {
               if (v.zy_type === "0") {
                 ADataArr.push({
-                  name: this.classTextToIndex["浦东新区行政区划"].get(v.zy_town),
+                  name: this.classTextToIndex["浦东新区行政区划"].get(
+                    v.zy_town
+                  ),
                   soil: v.c_land_area,
                   other: v.other_area,
                   forest: v.c_forest_area,
-                  sum: v.c_land_area + v.other_area + v.c_forest_area
+                  sum: v.c_land_area + v.other_area + v.c_forest_area,
                 });
               }
               if (v.zy_type === "1") {
                 BDataArr.push({
-                  name: this.classTextToIndex["浦东新区行政区划"].get(v.zy_town),
+                  name: this.classTextToIndex["浦东新区行政区划"].get(
+                    v.zy_town
+                  ),
                   soil: v.c_land_area,
                   other: v.other_area,
                   forest: v.c_forest_area,
-                  sum: v.c_land_area + v.other_area + v.c_forest_area
+                  sum: v.c_land_area + v.other_area + v.c_forest_area,
                 });
               }
               if (v.zy_type === "2") {
                 CDataArr.push({
-                  name: this.classTextToIndex["浦东新区行政区划"].get(v.zy_town),
+                  name: this.classTextToIndex["浦东新区行政区划"].get(
+                    v.zy_town
+                  ),
                   soil: v.c_land_area,
                   other: v.other_area,
                   forest: v.c_forest_area,
-                  sum: v.c_land_area + v.other_area + v.c_forest_area
+                  sum: v.c_land_area + v.other_area + v.c_forest_area,
                 });
               }
             });
@@ -400,20 +428,20 @@ export default {
             CDataArr.sort(publicFun.compare("sum"));
 
             // 按A,B,C分出各自资源的排序数组
-            ADataArr.forEach(item => {
+            ADataArr.forEach((item) => {
               this.AData.soil.push(item.soil);
               this.AData.other.push(item.other);
               this.AData.forestry.push(item.forest);
               this.AData.categoryData.push(item.name);
             });
-            BDataArr.forEach(item => {
+            BDataArr.forEach((item) => {
               this.BData.soil.push(item.soil);
               this.BData.other.push(item.other);
               this.BData.forestry.push(item.forest);
               this.BData.categoryData.push(item.name);
             });
 
-            CDataArr.forEach(item => {
+            CDataArr.forEach((item) => {
               this.CData.soil.push(item.soil);
               this.CData.other.push(item.other);
               this.CData.forestry.push(item.forest);
@@ -432,10 +460,10 @@ export default {
             });
           }
         })
-        .catch(error => {
+        .catch((error) => {
           console.log(error, "getSourcesData");
         });
-    }
+    },
   },
   created() {
     this.classDictQuery("0", "浦东新区行政区划", "浦东新区行政区划");
@@ -444,10 +472,10 @@ export default {
     for (let key in street) {
       this.streetOptions.push({
         value: street[key],
-        label: street[key]
+        label: street[key],
       });
     }
-  }
+  },
 };
 </script>
 <style lang="less" scoped>
@@ -567,7 +595,8 @@ export default {
 // }
 
 /* 频发问题 */
-#FrequencyContainer,#IndexSystemContainer {
+#FrequencyContainer,
+#IndexSystemContainer {
   position: relative;
   height: calc(100% - 60px);
   width: 100%;
@@ -749,14 +778,22 @@ export default {
     transform: translate(-50%, -50%) rotate(45deg);
     width: 110px;
     height: 100px;
-    background: linear-gradient(to left, @commonBorderColor, @commonBorderColor) left top no-repeat,
-      linear-gradient(to bottom, @commonBorderColor, @commonBorderColor) left top no-repeat,
-      linear-gradient(to left, @commonBorderColor, @commonBorderColor) right top no-repeat,
-      linear-gradient(to bottom, @commonBorderColor, @commonBorderColor) right top no-repeat,
-      linear-gradient(to left, @commonBorderColor, @commonBorderColor) left bottom no-repeat,
-      linear-gradient(to bottom, @commonBorderColor, @commonBorderColor) left bottom no-repeat,
-      linear-gradient(to left, @commonBorderColor, @commonBorderColor) right bottom no-repeat,
-      linear-gradient(to left, @commonBorderColor, @commonBorderColor) right bottom no-repeat;
+    background: linear-gradient(to left, @commonBorderColor, @commonBorderColor)
+        left top no-repeat,
+      linear-gradient(to bottom, @commonBorderColor, @commonBorderColor) left
+        top no-repeat,
+      linear-gradient(to left, @commonBorderColor, @commonBorderColor) right top
+        no-repeat,
+      linear-gradient(to bottom, @commonBorderColor, @commonBorderColor) right
+        top no-repeat,
+      linear-gradient(to left, @commonBorderColor, @commonBorderColor) left
+        bottom no-repeat,
+      linear-gradient(to bottom, @commonBorderColor, @commonBorderColor) left
+        bottom no-repeat,
+      linear-gradient(to left, @commonBorderColor, @commonBorderColor) right
+        bottom no-repeat,
+      linear-gradient(to left, @commonBorderColor, @commonBorderColor) right
+        bottom no-repeat;
     background-size: 6px 6px, 6px 6px, 6px 6px, 6px 6px;
   }
 }