From c0d57ad005630ea16f56d804172980dab523a714 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 21 Nov 2017 09:55:52 +0100 Subject: [PATCH] Allow string to be passed as ol.interaction.Draw type --- examples/draw-and-modify-features.js | 2 +- examples/draw-features.js | 2 +- examples/draw-freehand.js | 2 +- examples/draw-shapes.js | 2 +- examples/line-arrows.js | 2 +- examples/measure.js | 2 +- examples/snap.js | 8 ++++---- examples/vector-esri-edit.js | 2 +- externs/olx.js | 4 ++-- src/ol/interaction/draw.js | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/draw-and-modify-features.js b/examples/draw-and-modify-features.js index b2305ce0d3..6cc47d6213 100644 --- a/examples/draw-and-modify-features.js +++ b/examples/draw-and-modify-features.js @@ -54,7 +54,7 @@ var typeSelect = document.getElementById('type'); function addInteractions() { draw = new ol.interaction.Draw({ source: source, - type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) + type: typeSelect.value }); map.addInteraction(draw); snap = new ol.interaction.Snap({source: source}); diff --git a/examples/draw-features.js b/examples/draw-features.js index a7c77aeb07..641c8e064c 100644 --- a/examples/draw-features.js +++ b/examples/draw-features.js @@ -33,7 +33,7 @@ function addInteraction() { if (value !== 'None') { draw = new ol.interaction.Draw({ source: source, - type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) + type: typeSelect.value }); map.addInteraction(draw); } diff --git a/examples/draw-freehand.js b/examples/draw-freehand.js index 01ef780b00..f64e9366c4 100644 --- a/examples/draw-freehand.js +++ b/examples/draw-freehand.js @@ -33,7 +33,7 @@ function addInteraction() { if (value !== 'None') { draw = new ol.interaction.Draw({ source: source, - type: /** @type {ol.geom.GeometryType} */ (typeSelect.value), + type: typeSelect.value, freehand: true }); map.addInteraction(draw); diff --git a/examples/draw-shapes.js b/examples/draw-shapes.js index b305802d6f..396092a664 100644 --- a/examples/draw-shapes.js +++ b/examples/draw-shapes.js @@ -67,7 +67,7 @@ function addInteraction() { } draw = new ol.interaction.Draw({ source: source, - type: /** @type {ol.geom.GeometryType} */ (value), + type: value, geometryFunction: geometryFunction }); map.addInteraction(draw); diff --git a/examples/line-arrows.js b/examples/line-arrows.js index 423b305811..ee13201a7e 100644 --- a/examples/line-arrows.js +++ b/examples/line-arrows.js @@ -62,5 +62,5 @@ var map = new ol.Map({ map.addInteraction(new ol.interaction.Draw({ source: source, - type: /** @type {ol.geom.GeometryType} */ ('LineString') + type: 'LineString' })); diff --git a/examples/measure.js b/examples/measure.js index 30c2dfaf11..6f09548a0b 100644 --- a/examples/measure.js +++ b/examples/measure.js @@ -179,7 +179,7 @@ function addInteraction() { var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString'); draw = new ol.interaction.Draw({ source: source, - type: /** @type {ol.geom.GeometryType} */ (type), + type: type, style: new ol.style.Style({ fill: new ol.style.Fill({ color: 'rgba(255, 255, 255, 0.2)' diff --git a/examples/snap.js b/examples/snap.js index cd1764266d..0ac9206b5c 100644 --- a/examples/snap.js +++ b/examples/snap.js @@ -86,19 +86,19 @@ var Draw = { }, Point: new ol.interaction.Draw({ source: vector.getSource(), - type: /** @type {ol.geom.GeometryType} */ ('Point') + type: 'Point' }), LineString: new ol.interaction.Draw({ source: vector.getSource(), - type: /** @type {ol.geom.GeometryType} */ ('LineString') + type: 'LineString' }), Polygon: new ol.interaction.Draw({ source: vector.getSource(), - type: /** @type {ol.geom.GeometryType} */ ('Polygon') + type: 'Polygon' }), Circle: new ol.interaction.Draw({ source: vector.getSource(), - type: /** @type {ol.geom.GeometryType} */ ('Circle') + type: 'Circle' }), getActive: function() { return this.activeType ? this[this.activeType].getActive() : false; diff --git a/examples/vector-esri-edit.js b/examples/vector-esri-edit.js index b96f432700..b4ca7d9526 100644 --- a/examples/vector-esri-edit.js +++ b/examples/vector-esri-edit.js @@ -64,7 +64,7 @@ var raster = new ol.layer.Tile({ var draw = new ol.interaction.Draw({ source: vectorSource, - type: /** @type {ol.geom.GeometryType} */ ('Polygon') + type: 'Polygon' }); var select = new ol.interaction.Select(); diff --git a/externs/olx.js b/externs/olx.js index 404a6eba61..04f2e30660 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -3004,7 +3004,7 @@ olx.interaction.DragZoomOptions.prototype.out; * features: (ol.Collection.|undefined), * source: (ol.source.Vector|undefined), * snapTolerance: (number|undefined), - * type: ol.geom.GeometryType, + * type: (ol.geom.GeometryType|string), * maxPoints: (number|undefined), * minPoints: (number|undefined), * finishCondition: (ol.EventsConditionType|undefined), @@ -3058,7 +3058,7 @@ olx.interaction.DrawOptions.prototype.snapTolerance; /** * Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint', * 'MultiLineString', 'MultiPolygon' or 'Circle'). - * @type {ol.geom.GeometryType} + * @type {ol.geom.GeometryType|string} * @api */ olx.interaction.DrawOptions.prototype.type; diff --git a/src/ol/interaction/draw.js b/src/ol/interaction/draw.js index 5bb78a54b1..db70bf0efc 100644 --- a/src/ol/interaction/draw.js +++ b/src/ol/interaction/draw.js @@ -88,7 +88,7 @@ ol.interaction.Draw = function(options) { * @type {ol.geom.GeometryType} * @private */ - this.type_ = options.type; + this.type_ = /** @type {ol.geom.GeometryType} */ (options.type); /** * Drawing mode (derived from geometry type.