Add "None" to draw-features example's select

This allows to deactivate drawing entirely in the example.
This commit is contained in:
Éric Lemoine
2014-06-18 08:26:45 +02:00
parent 758f326215
commit a7b4a08e07
2 changed files with 9 additions and 5 deletions

View File

@@ -36,6 +36,7 @@
<form class="form-inline">
<label>Geometry type &nbsp;</label>
<select id="type">
<option value="None">None</option>
<option value="Point">Point</option>
<option value="LineString">LineString</option>
<option value="Polygon">Polygon</option>

View File

@@ -49,11 +49,14 @@ var typeSelect = document.getElementById('type');
var draw; // global so we can remove it later
function addInteraction() {
draw = new ol.interaction.Draw({
source: source,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
});
map.addInteraction(draw);
var value = typeSelect.value;
if (value !== 'None') {
draw = new ol.interaction.Draw({
source: source,
type: /** @type {ol.geom.GeometryType} */ (value)
});
map.addInteraction(draw);
}
}