Allow string to be passed as ol.interaction.Draw type

This commit is contained in:
Frederic Junod
2017-11-21 09:55:52 +01:00
parent ae6ba195f7
commit c0d57ad005
10 changed files with 14 additions and 14 deletions

View File

@@ -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});

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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'
}));

View File

@@ -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)'

View File

@@ -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;

View File

@@ -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();

View File

@@ -3004,7 +3004,7 @@ olx.interaction.DragZoomOptions.prototype.out;
* features: (ol.Collection.<ol.Feature>|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;

View File

@@ -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.