Explorar el Código

添加内网底图服务(暂时注释)。

DESKTOP-6LTVLN7\Liumouren hace 2 años
padre
commit
d990d63a7a
Se han modificado 1 ficheros con 44 adiciones y 47 borrados
  1. 44 47
      src/components/map/MapHolder.vue

+ 44 - 47
src/components/map/MapHolder.vue

@@ -21,7 +21,7 @@ export default {
       auditPopupStatus: "normal",
       popup: null,
       currentCid: null,
-      currentHtml: null,
+      currentHtml: null
     };
   },
   mounted() {
@@ -47,7 +47,7 @@ export default {
     this.$store.state.mapMethodsCollection.set("RENDER", {
       addPolygonLayer: this.addPolygonLayer,
       setView: this.setView,
-      deletePolygonLayer: this.deletePolygonLayer,
+      deletePolygonLayer: this.deletePolygonLayer
     });
   },
   beforeDestroyed() {
@@ -109,14 +109,14 @@ export default {
         $(() => {
           // 法律法规点击事件
           if ($(`#${str}_id a`)) {
-            $(`#${str}_id a`).click((e) => {
+            $(`#${str}_id a`).click(e => {
               console.log(e, "显示疑点相关的弹窗");
               this.$store.state.lawPopupShow = true;
             });
           }
           // input添加点击事件
           if ($(`#${str}_id input`)[1]) {
-            $(`#${str}_id input`).click((e) => {
+            $(`#${str}_id input`).click(e => {
               switch (e.target.defaultValue) {
                 case "修改":
                   this.modifyBtnEvent();
@@ -145,9 +145,7 @@ 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 {
         map2DViewer.map.removeControl(map2DViewer.jlControl);
         map2DViewer.map.removeLayer(map2DViewer.jlMap);
@@ -161,9 +159,7 @@ export default {
       // 每次点击按钮后重绘弹窗
       if (this.currentHtml && this.currentCid) {
         setTimeout(() => {
-          this.popup
-            .setContent(this.createDynamicDiv(this.currentCid))
-            .openOn(map2DViewer.map);
+          this.popup.setContent(this.createDynamicDiv(this.currentCid)).openOn(map2DViewer.map);
         }, 300);
       }
     },
@@ -191,22 +187,26 @@ export default {
     },
 
     mapInit: function () {
-      var crs = new L.Proj.CRS(
-        "EPSG:2401",
-        "+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=-3457147.81 +y_0=0 +ellps=krass +units=m +no_defs",
-        {
-          resolutions: [
-            529.1666666666666, 264.5833333333333, 132.29166666666666,
-            52.916666666666664, 26.458333333333332, 13.229166666666666,
-            5.291666666666666, 2.645833333333333, 1.3229166666666665,
-            0.5291666666666666, 0.2645833333333333, 0.13229166666666664,
-          ],
-          origin: [-66000, 75000],
-          bounds: L.bounds([-65000, -76000], [75000, 72000]),
-        }
-      );
+      // var crs = new L.Proj.CRS(
+      //   "EPSG:2401",
+      //   "+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: [
+      //       529.1666666666666, 264.5833333333333, 132.29166666666666, 52.916666666666664, 26.458333333333332,
+      //       13.229166666666666, 5.291666666666666, 2.645833333333333, 1.3229166666666665, 0.5291666666666666,
+      //       0.2645833333333333, 0.13229166666666664
+      //     ],
+      //     origin: [-66000, 75000],
+      //     bounds: L.bounds([-65000, -76000], [75000, 72000])
+      //   }
+      // );
+
       map2DViewer.map = L.map("map2DViewer", {
         // crs: crs,
+        // center: [31.074472887639914, 121.72521988031804],
+        // zoom: 1,
+        // minZoom: 1,
+        // maxZoom: 12
         attributionControl: false,
         zoomControl: false,
         minZoom: 10,
@@ -218,10 +218,11 @@ export default {
       var layer = L.esri
         .tiledMapLayer({
           url:
-            // "http://aimap.pudong.sh:5236/maps/rest/services/basemap-shanghai-gem-blue-sh2000/mapserver?AccessKey=MYldfdnrz5tuJPQN6dYLQqfazKdeoXx3QZtko4LKNovAS7Pm6Cr68lTrKcxOpsxw"
-            systemConfig.mapService +
-            "?servertype=Street_Purplish_Blue&token=" +
-            systemConfig.token,
+          systemConfig.mapService +
+          "?servertype=Street_Purplish_Blue&token=" +
+          systemConfig.token,
+          // url: "http://aimap.pudong.sh:5236/maps/rest/services/basemap-shanghai-gem-blue-sh2000/mapserver",
+          // tileSize: 512
         })
         .addTo(map2DViewer.map);
       layer.guid = guid;
@@ -232,11 +233,9 @@ export default {
       if (!map2DViewer.map) {
         this.mapInit();
       } else {
-        get("./static/json/pdgeojson.json", "").then((geoJson) => {
-          geoJson.features.map((feature) => {
-            if (
-              this.town.indexOf(feature.properties.NAME.replace("镇", "")) > -1
-            ) {
+        get("./static/json/pdgeojson.json", "").then(geoJson => {
+          geoJson.features.map(feature => {
+            if (this.town.indexOf(feature.properties.NAME.replace("镇", "")) > -1) {
               let center = turf.center(feature.geometry);
               this.renderPolygon(feature);
             }
@@ -259,7 +258,7 @@ export default {
         weight: 3,
         fillColor: this.getColor(itemvalue),
         opacity: 1,
-        fillOpacity: 0.4,
+        fillOpacity: 0.4
       }).addTo(map2DViewer.map);
       center = JSON.parse(JSON.stringify(center)).geometry.coordinates;
       center.reverse();
@@ -267,25 +266,25 @@ 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.map);
       L.circleMarker(center, {
         radius: 8,
         weight: 1,
         fillOpacity: 0,
-        color: "#e6d273",
+        color: "#e6d273"
       }).addTo(map2DViewer.map);
       L.circleMarker(center, {
         radius: 5,
         weight: 1,
         fillOpacity: 1,
-        color: "#e6d273",
+        color: "#e6d273"
       }).addTo(map2DViewer.map);
     },
     latLngsToReverse: function (latlngsAry) {
@@ -313,7 +312,7 @@ export default {
     addPolygonLayer(data, cid, color) {
       // cid -- 'yongjiu'
       // console.log(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;
@@ -322,17 +321,15 @@ 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;
 
-          this.popup = L.popup({ maxWidth: 700, maxHeight: 600 })
-            .setLatLng(e.latlng)
-            .setContent(this.createDynamicDiv("cid"));
+          this.popup = L.popup({ maxWidth: 700, maxHeight: 600 }).setLatLng(e.latlng).setContent(this.createDynamicDiv("cid"));
           // .openOn(map2DViewer.map);
           this.auditPopupShow = false;
           this.popup.openOn(map2DViewer.map);
@@ -344,11 +341,11 @@ export default {
 
     //综合分析 - 标记疑点 - 删除面
     deletePolygonLayer(layer) {
-      map2DViewer.polygons[layer].forEach((polygon) => {
+      map2DViewer.polygons[layer].forEach(polygon => {
         map2DViewer.map.removeLayer(polygon);
       });
-    },
-  },
+    }
+  }
 };
 </script>
 <style scoped>