Parcourir la source

上传文件文件解析

DESKTOP-6LTVLN7\Liumouren il y a 2 ans
Parent
commit
a8c95a2e0a
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      src/components/common/BottomForm/UploadingData.vue

+ 6 - 7
src/components/common/BottomForm/UploadingData.vue

@@ -123,20 +123,19 @@ export default {
     },
     // 根据上传的文件渲染到地图中
     uploadRENDER(geoJson) {
-      debugger
       map2DViewer.polygons[`upload_layer`] = [];
       // let cid = "upload";
       // let color = "#67C23A";
       // let guid = publicFun.buildGuid("myLayer");
       // uploadDataIdArr.push({
       //   id: guid,
-
       // });
       // 地图定位
-      let firstPolygon = JSON.parse(JSON.stringify(geoJson[0]));
-      let coordinates = firstPolygon.geometry.coordinates[0][0][0];
-      this.$store.state.mapMethodsCollection.get("RENDER").setView(coordinates, 16);
-      this.$store.state.mapMethodsCollection.get("RENDER").addPolygonLayer(geoJson, cid, color);
+      let firstPolygon = JSON.parse(JSON.stringify(geoJson));
+      console.log("上传文件读取到的数据",firstPolygon);
+      // let coordinates = firstPolygon.features.coordinates[0][0][0];
+      // this.$store.state.mapMethodsCollection.get("RENDER").setView(firstPolygon, 16);
+      // this.$store.state.mapMethodsCollection.get("RENDER").addPolygonLayer(geoJson, cid, color);
     },
     // 读取file对象内容
     getActionData(file) {
@@ -152,7 +151,7 @@ export default {
     },
     // 上传文件之前
     beforeAvatarUpload(file) {
-      const isJPG = file.type === "application/json" || file.type === "GeoJSON";
+      const isJPG = file.name.indexOf(".geojson") === file.name.length - 8;
       const isLt5M = file.size / 1024 / 1024 < 5;
       if (!isJPG) {
         this.$message.error("仅支持Geojson格式文件!");