Ver código fonte

Merge branch 'polygon_and_line_modify' into 'master'

修改线形和多边形

See merge request BA/amap-shapes-generator!24
wd 7 anos atrás
pai
commit
a50da01a34
1 arquivos alterados com 4 adições e 1 exclusões
  1. 4 1
      index.js

+ 4 - 1
index.js

@@ -240,7 +240,7 @@ function getLinesRouter(lineProps, lineAndMarkerStyle) {
                 coordinates = []
 
                 const pointBefore = i == 0 ? startPoint : passPoints[i - 1]
-                const pointAfter = i == passPoints.length - 1 ? endPoint : passPoints[i + 1]
+                const pointAfter = i == passPoints.length - 1 ? (endPoint ? endPoint : passPoints[passPoints.length - 1]) : passPoints[i + 1]
 
                 lines.push({lineWidth, strokeColor, coordinates: getAirwayPoints(obj, pointBefore, pointAfter)})
             }
@@ -381,6 +381,9 @@ function getPolygon(polygonProps, polygonAndMarkerStyle) {
 
     if (Array.isArray(polygonProps[pointsFix])) {
         for (let obj of polygonProps[pointsFix]) {
+            if (!obj) {
+                continue
+            }
             coordinates.push(drawLineConfig(obj.lat, obj.lng, dataType));
             markers.push(addOvalPointConfig(obj.lat, obj.lng, imageName, dataType));
         }