summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/snap-grid.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/snap-grid.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/snap-grid.js')
-rw-r--r--misc/openlayers/examples/snap-grid.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/misc/openlayers/examples/snap-grid.js b/misc/openlayers/examples/snap-grid.js
new file mode 100644
index 0000000..4478c5a
--- /dev/null
+++ b/misc/openlayers/examples/snap-grid.js
@@ -0,0 +1,81 @@
+var points = new OpenLayers.Layer.PointGrid({
+ name: "Snap Grid",
+ dx: 600, dy: 600,
+ styleMap: new OpenLayers.StyleMap({
+ pointRadius: 1,
+ strokeColor: "#3333ff",
+ strokeWidth: 1,
+ fillOpacity: 1,
+ fillColor: "#ffffff",
+ graphicName: "square"
+ })
+});
+
+var lines = new OpenLayers.Layer.Vector("Lines", {
+ styleMap: new OpenLayers.StyleMap({
+ pointRadius: 3,
+ strokeColor: "#ff3300",
+ strokeWidth: 3,
+ fillOpacity: 0
+ })
+});
+
+var map = new OpenLayers.Map({
+ div: "map",
+ layers: [new OpenLayers.Layer.OSM(), points, lines],
+ controls: [
+ new OpenLayers.Control.Navigation(),
+ new OpenLayers.Control.LayerSwitcher(),
+ new OpenLayers.Control.Attribution()
+ ],
+ restrictedExtent: new OpenLayers.Bounds(
+ 1035374, 7448940, 1074510, 7468508
+ ),
+ center: new OpenLayers.LonLat(1054942, 7458724),
+ zoom: 13
+});
+
+// configure the snapping agent
+var snap = new OpenLayers.Control.Snapping({
+ layer: lines,
+ targets: [{
+ layer: points,
+ tolerance: 15
+ }]
+});
+snap.activate();
+
+// add some editing tools to a panel
+var panel = new OpenLayers.Control.Panel({
+ displayClass: "olControlEditingToolbar"
+});
+var draw = new OpenLayers.Control.DrawFeature(
+ lines, OpenLayers.Handler.Path,
+ {displayClass: "olControlDrawFeaturePath", title: "Draw Features"}
+);
+modify = new OpenLayers.Control.ModifyFeature(
+ lines, {displayClass: "olControlModifyFeature", title: "Modify Features"}
+);
+panel.addControls([
+ new OpenLayers.Control.Navigation({title: "Navigate"}),
+ modify, draw
+]);
+map.addControl(panel);
+
+var rotation = document.getElementById("rotation");
+rotation.value = String(points.rotation);
+rotation.onchange = function() {
+ points.setRotation(Number(rotation.value));
+};
+
+var spacing = document.getElementById("spacing");
+spacing.value = String(points.dx);
+spacing.onchange = function() {
+ points.setSpacing(Number(spacing.value));
+};
+
+var max = document.getElementById("max");
+max.value = String(points.maxFeatures);
+max.onchange = function() {
+ points.setMaxFeatures(Number(max.value));
+};