1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>SelectFeature Control for Select and Highlight</title>
4 <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
5 <link rel="stylesheet" href="style.css" type="text/css" />
6 <style type="text/css">
11 <script src="../lib/Firebug/firebug.js"></script>
12 <script src="../lib/OpenLayers.js"></script>
13 <script type="text/javascript">
17 OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
20 map = new OpenLayers.Map('map');
22 var vectors = new OpenLayers.Layer.Vector("vector", {isBaseLayer: true});
23 map.addLayers([vectors]);
25 var feature = new OpenLayers.Feature.Vector(
26 OpenLayers.Geometry.fromWKT(
27 "POLYGON((28.828125 0.3515625, 132.1875 -13.0078125, -1.40625 -59.4140625, 28.828125 0.3515625))"
30 vectors.addFeatures([feature]);
32 var feature2 = new OpenLayers.Feature.Vector(
33 OpenLayers.Geometry.fromWKT(
34 "POLYGON((-120.828125 -50.3515625, -80.1875 -80.0078125, -40.40625 -20.4140625, -120.828125 -50.3515625))"
37 vectors.addFeatures([feature2]);
39 var report = function(e) {
40 OpenLayers.Console.log(e.type, e.feature.id);
43 var highlightCtrl = new OpenLayers.Control.SelectFeature(vectors, {
46 renderIntent: "temporary",
48 beforefeaturehighlighted: report,
49 featurehighlighted: report,
50 featureunhighlighted: report
54 var selectCtrl = new OpenLayers.Control.SelectFeature(vectors,
58 map.addControl(highlightCtrl);
59 map.addControl(selectCtrl);
61 highlightCtrl.activate();
62 selectCtrl.activate();
64 map.addControl(new OpenLayers.Control.EditingToolbar(vectors));
66 map.setCenter(new OpenLayers.LonLat(0, 0), 1);
71 <body onload="init()">
72 <h1 id="title">OpenLayers Select and Highlight Feature Example</h1>
74 Select features on click, highlight features on hover.
76 <div id="map" class="smallmap"></div>
77 <p>Select features by clicking on them. Just highlight features by hovering over