Add convenience function to create a regular polygon geometryFunction

This commit is contained in:
Andreas Hocevar
2015-05-08 11:21:16 +02:00
parent 901a0f6d8e
commit 19c91235ce
4 changed files with 77 additions and 2 deletions

View File

@@ -51,9 +51,16 @@ var draw; // global so we can remove it later
function addInteraction() {
var value = typeSelect.value;
if (value !== 'None') {
var geometryFunction;
if (value === 'Square') {
value = 'Circle';
geometryFunction =
ol.interaction.Draw.createRegularPolygon(4, Math.PI / 4);
}
draw = new ol.interaction.Draw({
source: source,
type: /** @type {ol.geom.GeometryType} */ (value)
type: /** @type {ol.geom.GeometryType} */ (value),
geometryFunction: geometryFunction
});
map.addInteraction(draw);
}