summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/editing-methods.js
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
committerChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
commitea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch)
treeaf67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/examples/editing-methods.js
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/examples/editing-methods.js')
-rw-r--r--misc/openlayers/examples/editing-methods.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/misc/openlayers/examples/editing-methods.js b/misc/openlayers/examples/editing-methods.js
new file mode 100644
index 0000000..03d5e82
--- /dev/null
+++ b/misc/openlayers/examples/editing-methods.js
@@ -0,0 +1,83 @@
+var map = new OpenLayers.Map({
+ div: "map",
+ layers: [
+ new OpenLayers.Layer.WMS(
+ "Global Imagery",
+ "http://maps.opengeo.org/geowebcache/service/wms",
+ {layers: "bluemarble"},
+ {tileOrigin: new OpenLayers.LonLat(-180, -90)}
+ ),
+ new OpenLayers.Layer.Vector()
+ ],
+ center: new OpenLayers.LonLat(0, 0),
+ zoom: 1
+});
+
+var draw = new OpenLayers.Control.DrawFeature(
+ map.layers[1], OpenLayers.Handler.Path
+);
+map.addControl(draw);
+draw.activate();
+
+// handle clicks on method links
+document.getElementById("insertXY").onclick = function() {
+ var values = parseInput(
+ window.prompt(
+ "Enter map coordinates for new point (e.g. '-111, 46')", "x, y"
+ )
+ );
+ if (values != null) {
+ draw.insertXY(values[0], values[1]);
+ }
+};
+document.getElementById("insertDeltaXY").onclick = function() {
+ var values = parseInput(
+ window.prompt(
+ "Enter offset values for new point (e.g. '15, -10')", "dx, dy"
+ )
+ );
+ if (values != null) {
+ draw.insertDeltaXY(values[0], values[1]);
+ }
+};
+document.getElementById("insertDirectionLength").onclick = function() {
+ var values = parseInput(
+ window.prompt(
+ "Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length"
+ )
+ );
+ if (values != null) {
+ draw.insertDirectionLength(values[0], values[1]);
+ }
+};
+document.getElementById("insertDeflectionLength").onclick = function() {
+ var values = parseInput(
+ window.prompt(
+ "Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length"
+ )
+ );
+ if (values != null) {
+ draw.insertDeflectionLength(values[0], values[1]);
+ }
+};
+document.getElementById("cancel").onclick = function() {
+ draw.cancel();
+};
+document.getElementById("finishSketch").onclick = function() {
+ draw.finishSketch();
+};
+
+function parseInput(text) {
+ var values = text.split(",");
+ if (values.length !== 2) {
+ values = null;
+ } else {
+ values[0] = parseFloat(values[0]);
+ values[1] = parseFloat(values[1]);
+ if (isNaN(values[0]) || isNaN(values[1])) {
+ window.alert("The two values must be numeric.");
+ values = null;
+ }
+ }
+ return values;
+}