summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/feature-events.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/feature-events.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/feature-events.js')
-rw-r--r--misc/openlayers/examples/feature-events.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/misc/openlayers/examples/feature-events.js b/misc/openlayers/examples/feature-events.js
new file mode 100644
index 0000000..8a6fe28
--- /dev/null
+++ b/misc/openlayers/examples/feature-events.js
@@ -0,0 +1,67 @@
+var layerListeners = {
+ featureclick: function(e) {
+ log(e.object.name + " says: " + e.feature.id + " clicked.");
+ return false;
+ },
+ nofeatureclick: function(e) {
+ log(e.object.name + " says: No feature clicked.");
+ }
+};
+
+var style = new OpenLayers.StyleMap({
+ 'default': OpenLayers.Util.applyDefaults(
+ {label: "${l}", pointRadius: 10},
+ OpenLayers.Feature.Vector.style["default"]
+ ),
+ 'select': OpenLayers.Util.applyDefaults(
+ {pointRadius: 10},
+ OpenLayers.Feature.Vector.style.select
+ )
+});
+var layer1 = new OpenLayers.Layer.Vector("Layer 1", {
+ styleMap: style,
+ eventListeners: layerListeners
+});
+layer1.addFeatures([
+ new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT("POINT(-1 -1)"), {l:1}),
+ new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT("POINT(1 1)"), {l:1})
+]);
+var layer2 = new OpenLayers.Layer.Vector("Layer 2", {
+ styleMap: style,
+ eventListeners: layerListeners
+});
+layer2.addFeatures([
+ new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT("POINT(-1 1)"), {l:2}),
+ new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT("POINT(1 -1)"), {l:2})
+]);
+
+var map = new OpenLayers.Map({
+ div: "map",
+ allOverlays: true,
+ layers: [layer1, layer2],
+ zoom: 6,
+ center: [0, 0],
+ eventListeners: {
+ featureover: function(e) {
+ e.feature.renderIntent = "select";
+ e.feature.layer.drawFeature(e.feature);
+ log("Map says: Pointer entered " + e.feature.id + " on " + e.feature.layer.name);
+ },
+ featureout: function(e) {
+ e.feature.renderIntent = "default";
+ e.feature.layer.drawFeature(e.feature);
+ log("Map says: Pointer left " + e.feature.id + " on " + e.feature.layer.name);
+ },
+ featureclick: function(e) {
+ log("Map says: " + e.feature.id + " clicked on " + e.feature.layer.name);
+ }
+ }
+});
+
+function log(msg) {
+ if (!log.timer) {
+ result.innerHTML = "";
+ log.timer = window.setTimeout(function() {delete log.timer;}, 100);
+ }
+ result.innerHTML += msg + "<br>";
+}