Skip to content

Commit

Permalink
Add points to vertices when editing a geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault committed Oct 20, 2023
1 parent c7cd9da commit 86b81b1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion assets/src/modules/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Vector as VectorSource } from 'ol/source.js';
import { Vector as VectorLayer } from 'ol/layer.js';
import { Feature } from 'ol';

import { Point, LineString, Polygon, Circle as CircleGeom } from 'ol/geom.js';
import { Point, LineString, Polygon, Circle as CircleGeom, MultiPoint } from 'ol/geom.js';
import { circular } from 'ol/geom/Polygon.js';

import { getArea, getLength } from 'ol/sphere.js';
Expand Down Expand Up @@ -108,6 +108,24 @@ export default class Digitizing {
width: this._strokeWidth
}),
}),
new Style({
image: new Circle({
radius: 5,
fill: new Fill({
color: color,
}),
}),
geometry: feature => {
const geometryType = feature.getGeometry().getType();
if (geometryType === "LineString") {
return new MultiPoint(feature.getGeometry().getCoordinates());
}
if (geometryType === "Polygon") {
// return the coordinates of the first ring of the polygon
return new MultiPoint(feature.getGeometry().getCoordinates()[0]);
}
},
}),
];
}
});
Expand Down

0 comments on commit 86b81b1

Please sign in to comment.