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/select-feature-multilayer.html | |
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/select-feature-multilayer.html')
-rw-r--r-- | misc/openlayers/examples/select-feature-multilayer.html | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/misc/openlayers/examples/select-feature-multilayer.html b/misc/openlayers/examples/select-feature-multilayer.html new file mode 100644 index 0000000..6b8f3f4 --- /dev/null +++ b/misc/openlayers/examples/select-feature-multilayer.html @@ -0,0 +1,129 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> + <meta name="apple-mobile-web-app-capable" content="yes"> + <title>SelectFeature Control on multiple vector layers</title> + <link rel="stylesheet" href="../theme/default/style.css" type="text/css"> + <link rel="stylesheet" href="style.css" type="text/css"> + <style type="text/css"> + #controlToggle li { + list-style: none; + } + </style> + <script src="../lib/OpenLayers.js"></script> + <script type="text/javascript"> + var map, selectControl; + OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2'; + function init(){ + map = new OpenLayers.Map('map'); + var wmsLayer = new OpenLayers.Layer.WMS( + "OpenLayers WMS", + "http://vmap0.tiles.osgeo.org/wms/vmap0", + {layers: 'basic'} + ); + + // 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 vectors1 = new OpenLayers.Layer.Vector("Vector Layer 1", { + renderers: renderer, + styleMap: new OpenLayers.StyleMap({ + "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({ + externalGraphic: "../img/marker-green.png", + graphicOpacity: 1, + rotation: -45, + pointRadius: 10 + }, OpenLayers.Feature.Vector.style["default"])), + "select": new OpenLayers.Style({ + externalGraphic: "../img/marker-blue.png" + }) + }) + }); + var vectors2 = new OpenLayers.Layer.Vector("Vector Layer 2", { + renderers: renderer, + styleMap: new OpenLayers.StyleMap({ + "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({ + fillColor: "red", + strokeColor: "gray", + graphicName: "square", + rotation: 45, + pointRadius: 15 + }, OpenLayers.Feature.Vector.style["default"])), + "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({ + graphicName: "square", + rotation: 45, + pointRadius: 15 + }, OpenLayers.Feature.Vector.style["select"])) + }) + }); + map.addLayers([wmsLayer, vectors1, vectors2]); + map.addControl(new OpenLayers.Control.LayerSwitcher()); + + selectControl = new OpenLayers.Control.SelectFeature( + [vectors1, vectors2], + { + clickout: true, toggle: false, + multiple: false, hover: false, + toggleKey: "ctrlKey", // ctrl key removes from selection + multipleKey: "shiftKey" // shift key adds to selection + } + ); + + map.addControl(selectControl); + selectControl.activate(); + map.setCenter(new OpenLayers.LonLat(0, 0), 3); + vectors1.addFeatures(createFeatures()); + vectors2.addFeatures(createFeatures()); + + vectors1.events.on({ + "featureselected": function(e) { + showStatus("selected feature "+e.feature.id+" on Vector Layer 1"); + }, + "featureunselected": function(e) { + showStatus("unselected feature "+e.feature.id+" on Vector Layer 1"); + } + }); + vectors2.events.on({ + "featureselected": function(e) { + showStatus("selected feature "+e.feature.id+" on Vector Layer 2"); + }, + "featureunselected": function(e) { + showStatus("unselected feature "+e.feature.id+" on Vector Layer 2"); + } + }); + } + + function createFeatures() { + var extent = map.getExtent(); + var features = []; + for(var i=0; i<10; ++i) { + features.push(new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(extent.left + (extent.right - extent.left) * Math.random(), + extent.bottom + (extent.top - extent.bottom) * Math.random() + ))); + } + return features; + } + + function showStatus(text) { + document.getElementById("status").innerHTML = text; + } + + </script> + </head> + <body onload="init()"> + <h1 id="title">OpenLayers Select Feature on Multiple Layers Example</h1> + <div id="tags"> + vector, feature, selecting, selection, advanced, light + </div> + <p id="shortdesc"> + Select a feature on click with the Control.SelectFeature on multiple + vector layers. + </p> + <div id="map" class="smallmap"></div> + <div id="status"></div> + </body> +</html> |