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