Close polygon sketch at all times
This commit is contained in:
@@ -152,7 +152,11 @@ ol.interaction.Draw = function(options) {
|
||||
geometryFunction = function(coordinates, opt_geometry) {
|
||||
var geometry = opt_geometry;
|
||||
if (geometry) {
|
||||
geometry.setCoordinates(coordinates);
|
||||
if (mode === ol.interaction.Draw.Mode.POLYGON) {
|
||||
geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
|
||||
} else {
|
||||
geometry.setCoordinates(coordinates);
|
||||
}
|
||||
} else {
|
||||
geometry = new Constructor(coordinates);
|
||||
}
|
||||
@@ -617,12 +621,10 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
|
||||
coordinates.pop();
|
||||
this.geometryFunction_(coordinates, geometry);
|
||||
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
|
||||
// When we finish drawing a polygon on the last point,
|
||||
// the last coordinate is duplicated as for LineString
|
||||
// we force the replacement by the first point
|
||||
// remove the redundant last point in ring
|
||||
coordinates[0].pop();
|
||||
coordinates[0].push(coordinates[0][0]);
|
||||
this.geometryFunction_(coordinates, geometry);
|
||||
coordinates = geometry.getCoordinates();
|
||||
}
|
||||
|
||||
// cast multi-part geometries
|
||||
|
||||
Reference in New Issue
Block a user