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"> <form class="form-inline">
<label>Geometry type &nbsp;</label> <label>Geometry type &nbsp;</label>
<select id="type"> <select id="type">
<option value="None">None</option>
<option value="Point">Point</option> <option value="Point">Point</option>
<option value="LineString">LineString</option> <option value="LineString">LineString</option>
<option value="Polygon">Polygon</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 var draw; // global so we can remove it later
function addInteraction() { function addInteraction() {
draw = new ol.interaction.Draw({ var value = typeSelect.value;
source: source, if (value !== 'None') {
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) draw = new ol.interaction.Draw({
}); source: source,
map.addInteraction(draw); type: /** @type {ol.geom.GeometryType} */ (value)
});
map.addInteraction(draw);
}
} }