Changes snap example to allow Circle creations

This commit is contained in:
Thomas Chandelle
2017-05-23 11:04:46 +02:00
parent e272eced94
commit a1355ee766
2 changed files with 7 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ tags: "draw, edit, modify, vector, snap"
<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>
<option value="Circle">Circle</option>
</select> </select>
</div> </div>
</form> </form>

View File

@@ -81,6 +81,8 @@ var Draw = {
this.LineString.setActive(false); this.LineString.setActive(false);
map.addInteraction(this.Polygon); map.addInteraction(this.Polygon);
this.Polygon.setActive(false); this.Polygon.setActive(false);
map.addInteraction(this.Circle);
this.Circle.setActive(false);
}, },
Point: new ol.interaction.Draw({ Point: new ol.interaction.Draw({
source: vector.getSource(), source: vector.getSource(),
@@ -94,6 +96,10 @@ var Draw = {
source: vector.getSource(), source: vector.getSource(),
type: /** @type {ol.geom.GeometryType} */ ('Polygon') type: /** @type {ol.geom.GeometryType} */ ('Polygon')
}), }),
Circle: new ol.interaction.Draw({
source: vector.getSource(),
type: /** @type {ol.geom.GeometryType} */ ('Circle')
}),
getActive: function() { getActive: function() {
return this.activeType ? this[this.activeType].getActive() : false; return this.activeType ? this[this.activeType].getActive() : false;
}, },