blob: 067be62b807e5c83ecae4d33b8dc0459a32e877f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// allow testing of specific renderers via "?renderer=Canvas", etc
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;
var map = new OpenLayers.Map({
div: "map",
layers: [
new OpenLayers.Layer.OSM(),
new OpenLayers.Layer.Vector("Vector Layer", {
renderers: renderer
})
],
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;
|