Adding interior ring digitizing for polygons. Thanks jachym for the initial work. r=ahocevar (closes #1894)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10828 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
38
examples/donut.js
Normal file
38
examples/donut.js
Normal file
@@ -0,0 +1,38 @@
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [
|
||||
new OpenLayers.Layer.OSM(),
|
||||
new OpenLayers.Layer.Vector()
|
||||
],
|
||||
center: new OpenLayers.LonLat(0, 0),
|
||||
zoom: 1
|
||||
});
|
||||
|
||||
var draw = new OpenLayers.Control.DrawFeature(
|
||||
map.layers[1],
|
||||
OpenLayers.Handler.Polygon,
|
||||
{handlerOptions: {holeModifier: "altKey"}}
|
||||
);
|
||||
map.addControl(draw);
|
||||
|
||||
// optionally listen for sketch events on the layer
|
||||
var output = document.getElementById("output");
|
||||
function updateOutput(event) {
|
||||
window.setTimeout(function() {
|
||||
output.innerHTML = event.type + " " + event.feature.id;
|
||||
}, 100);
|
||||
}
|
||||
map.layers[1].events.on({
|
||||
sketchmodified: updateOutput,
|
||||
sketchcomplete: updateOutput
|
||||
})
|
||||
|
||||
// add behavior to UI elements
|
||||
function toggleControl(element) {
|
||||
if (element.value === "polygon" && element.checked) {
|
||||
draw.activate();
|
||||
} else {
|
||||
draw.deactivate();
|
||||
}
|
||||
}
|
||||
document.getElementById("noneToggle").checked = true;
|
||||
Reference in New Issue
Block a user