From 911e51e56ce5497768381bdda9de13880e035e56 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Wed, 13 Dec 2023 15:05:56 +0100 Subject: [PATCH] display vertices in cases of MultiPolygons too --- src/components/my-map/drawing.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/my-map/drawing.ts b/src/components/my-map/drawing.ts index ad4c57e1..5828af61 100644 --- a/src/components/my-map/drawing.ts +++ b/src/components/my-map/drawing.ts @@ -1,4 +1,4 @@ -import { MultiPoint, Polygon } from "ol/geom"; +import { MultiPoint, MultiPolygon, Polygon } from "ol/geom"; import { Draw, Modify, Snap } from "ol/interaction"; import { Vector as VectorLayer } from "ol/layer"; import { Vector as VectorSource } from "ol/source"; @@ -48,10 +48,13 @@ function polygonVertices(drawColor: string) { }), geometry: function (feature) { const geom = feature.getGeometry(); + // display the coordinates of the polygon(s) if (geom instanceof Polygon) { - // return the coordinates of the drawn polygon const coordinates = geom.getCoordinates()[0]; return new MultiPoint(coordinates); + } else if (geom instanceof MultiPolygon) { + const coordinates = geom.getCoordinates().flat(2); + return new MultiPoint(coordinates); } else { return; }