From 0baf4fe3f11ed33d2cb8830adb5aa48e1a115f03 Mon Sep 17 00:00:00 2001 From: Krzysztof Rzymkowski Date: Wed, 26 Apr 2017 19:04:54 +0200 Subject: [PATCH] [openlayers] ol.interaction.Draw.createBox() (#16130) --- types/openlayers/index.d.ts | 9 +++++++++ types/openlayers/openlayers-tests.ts | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index 2b721ab7ca..e863a28ad3 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -5255,6 +5255,15 @@ declare module ol { */ extend(feature: ol.Feature): void; + /** + * Create a `geometryFunction` that will create a box-shaped polygon (aligned + * with the coordinate system axes). Use this with the draw interaction and + * `type: 'Circle'` to return a box instead of a circle geometry. + * @return {ol.DrawGeometryFunctionType} Function that draws a box-shaped polygon. + * @api + */ + static createBox(): ol.DrawGeometryFunctionType; + /** * Create a `geometryFunction` for `mode: 'Circle'` that will create a regular * polygon with a user specified number of sides and start angle instead of an diff --git a/types/openlayers/openlayers-tests.ts b/types/openlayers/openlayers-tests.ts index ca74a6bbc2..01d12bf1b6 100644 --- a/types/openlayers/openlayers-tests.ts +++ b/types/openlayers/openlayers-tests.ts @@ -662,6 +662,12 @@ draw = new ol.interaction.Draw({ type: "Point", style: styleFunctionAsStyle }); +ol.interaction.Draw.createBox(); +ol.interaction.Draw.createRegularPolygon(); +ol.interaction.Draw.createRegularPolygon(4); +ol.interaction.Draw.createRegularPolygon(4,0); + + let styleFunctionAsArray = function(feature: ol.Feature, resolution: number): ol.style.Style[] { return styleArray; } draw = new ol.interaction.Draw({ type: "Point",