Skip to content

Commit

Permalink
fix: display drawGeojsonData vertices in cases of MultiPolygons too (
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Dec 13, 2023
1 parent 5bf230b commit 31872c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/my-map/drawing.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 31872c2

Please sign in to comment.