From a50a4efeca90d8187b9586147e3dd5df1a2b1fea Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sat, 4 Aug 2018 07:35:17 +0200 Subject: [PATCH] Don't create Polygon with null coordinates --- examples/draw-shapes.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/draw-shapes.js b/examples/draw-shapes.js index c99c94ffee..7ed90d5be0 100644 --- a/examples/draw-shapes.js +++ b/examples/draw-shapes.js @@ -40,9 +40,6 @@ function addInteraction() { } else if (value === 'Star') { value = 'Circle'; geometryFunction = function(coordinates, geometry) { - if (!geometry) { - geometry = new Polygon(null); - } const center = coordinates[0]; const last = coordinates[1]; const dx = center[0] - last[0]; @@ -59,7 +56,11 @@ function addInteraction() { newCoordinates.push([center[0] + offsetX, center[1] + offsetY]); } newCoordinates.push(newCoordinates[0].slice()); - geometry.setCoordinates([newCoordinates]); + if (!geometry) { + geometry = new Polygon([newCoordinates]); + } else { + geometry.setCoordinates([newCoordinates]); + } return geometry; }; }