diff options
author | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
commit | ea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch) | |
tree | af67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/examples/snap-grid.js | |
parent | 59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff) | |
download | postrunner-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.js | 81 |
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)); +}; |