Selaa lähdekoodia

解决有的元素不上图问题

zpf 10 kuukautta sitten
vanhempi
commit
c381ad000f
1 muutettua tiedostoa jossa 14 lisäystä ja 5 poistoa
  1. 14 5
      src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

+ 14 - 5
src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

@@ -103,13 +103,22 @@ export default {
             data.forEach((res) => {
                 res.type = '图斑上图'
                 if (res.geom) {
-                    res.geom.coordinates.forEach((res_coordinates,ei) => {
-                        res_coordinates.forEach(coord=>{
-                        const twoDArray = coord;
+
+                    let geojson = res.geom;
+                    if (geojson.type == 'MultiPolygon') {
+                        geojson.coordinates.forEach((res) => {
+                            const twoDArray = res[0];
+                            const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+
+                            tdsy.add(res, oneDArray);
+
+                        })
+
+                    } else {
+                        const twoDArray = geojson.coordinates[0];
                         const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
                         tdsy.add(res, oneDArray);
-                        })
-                    })
+                    }
                 }
             })
         },