Merge pull request #7489 from fredj/draw_type_string

Allow string to be passed as ol.interaction.Draw type
This commit is contained in:
Frédéric Junod
2017-11-22 08:58:45 +01:00
committed by GitHub
10 changed files with 14 additions and 14 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ var typeSelect = document.getElementById('type');
function addInteractions() { function addInteractions() {
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) type: typeSelect.value
}); });
map.addInteraction(draw); map.addInteraction(draw);
snap = new ol.interaction.Snap({source: source}); snap = new ol.interaction.Snap({source: source});
+1 -1
View File
@@ -33,7 +33,7 @@ function addInteraction() {
if (value !== 'None') { if (value !== 'None') {
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) type: typeSelect.value
}); });
map.addInteraction(draw); map.addInteraction(draw);
} }
+1 -1
View File
@@ -33,7 +33,7 @@ function addInteraction() {
if (value !== 'None') { if (value !== 'None') {
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value), type: typeSelect.value,
freehand: true freehand: true
}); });
map.addInteraction(draw); map.addInteraction(draw);
+1 -1
View File
@@ -67,7 +67,7 @@ function addInteraction() {
} }
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ (value), type: value,
geometryFunction: geometryFunction geometryFunction: geometryFunction
}); });
map.addInteraction(draw); map.addInteraction(draw);
+1 -1
View File
@@ -62,5 +62,5 @@ var map = new ol.Map({
map.addInteraction(new ol.interaction.Draw({ map.addInteraction(new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ ('LineString') type: 'LineString'
})); }));
+1 -1
View File
@@ -179,7 +179,7 @@ function addInteraction() {
var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString'); var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString');
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ (type), type: type,
style: new ol.style.Style({ style: new ol.style.Style({
fill: new ol.style.Fill({ fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)' color: 'rgba(255, 255, 255, 0.2)'
+4 -4
View File
@@ -86,19 +86,19 @@ var Draw = {
}, },
Point: new ol.interaction.Draw({ Point: new ol.interaction.Draw({
source: vector.getSource(), source: vector.getSource(),
type: /** @type {ol.geom.GeometryType} */ ('Point') type: 'Point'
}), }),
LineString: new ol.interaction.Draw({ LineString: new ol.interaction.Draw({
source: vector.getSource(), source: vector.getSource(),
type: /** @type {ol.geom.GeometryType} */ ('LineString') type: 'LineString'
}), }),
Polygon: new ol.interaction.Draw({ Polygon: new ol.interaction.Draw({
source: vector.getSource(), source: vector.getSource(),
type: /** @type {ol.geom.GeometryType} */ ('Polygon') type: 'Polygon'
}), }),
Circle: new ol.interaction.Draw({ Circle: new ol.interaction.Draw({
source: vector.getSource(), source: vector.getSource(),
type: /** @type {ol.geom.GeometryType} */ ('Circle') type: 'Circle'
}), }),
getActive: function() { getActive: function() {
return this.activeType ? this[this.activeType].getActive() : false; return this.activeType ? this[this.activeType].getActive() : false;
+1 -1
View File
@@ -64,7 +64,7 @@ var raster = new ol.layer.Tile({
var draw = new ol.interaction.Draw({ var draw = new ol.interaction.Draw({
source: vectorSource, source: vectorSource,
type: /** @type {ol.geom.GeometryType} */ ('Polygon') type: 'Polygon'
}); });
var select = new ol.interaction.Select(); var select = new ol.interaction.Select();
+2 -2
View File
@@ -3004,7 +3004,7 @@ olx.interaction.DragZoomOptions.prototype.out;
* features: (ol.Collection.<ol.Feature>|undefined), * features: (ol.Collection.<ol.Feature>|undefined),
* source: (ol.source.Vector|undefined), * source: (ol.source.Vector|undefined),
* snapTolerance: (number|undefined), * snapTolerance: (number|undefined),
* type: ol.geom.GeometryType, * type: (ol.geom.GeometryType|string),
* maxPoints: (number|undefined), * maxPoints: (number|undefined),
* minPoints: (number|undefined), * minPoints: (number|undefined),
* finishCondition: (ol.EventsConditionType|undefined), * finishCondition: (ol.EventsConditionType|undefined),
@@ -3058,7 +3058,7 @@ olx.interaction.DrawOptions.prototype.snapTolerance;
/** /**
* Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint', * Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint',
* 'MultiLineString', 'MultiPolygon' or 'Circle'). * 'MultiLineString', 'MultiPolygon' or 'Circle').
* @type {ol.geom.GeometryType} * @type {ol.geom.GeometryType|string}
* @api * @api
*/ */
olx.interaction.DrawOptions.prototype.type; olx.interaction.DrawOptions.prototype.type;
+1 -1
View File
@@ -88,7 +88,7 @@ ol.interaction.Draw = function(options) {
* @type {ol.geom.GeometryType} * @type {ol.geom.GeometryType}
* @private * @private
*/ */
this.type_ = options.type; this.type_ = /** @type {ol.geom.GeometryType} */ (options.type);
/** /**
* Drawing mode (derived from geometry type. * Drawing mode (derived from geometry type.