OpenLayers OpenLayers

root/branches/openlayers/2.5/examples/custom-control-point.html

Revision 4245, 1.5 kB (checked in by crschmidt, 1 year ago)

Add custom-control-point demo showing use of point handler to return data.

Line 
1 <html xmlns="http://www.w3.org/1999/xhtml">
2   <head>
3     <style type="text/css">
4         #map {
5             width: 800px;
6             height: 475px;
7             border: 1px solid black;
8         }
9     </style>
10     <script src="../lib/OpenLayers.js"></script>
11     <script type="text/javascript">
12         <!--
13         var lon = 5;
14         var lat = 40;
15         var zoom = 5;
16         var map, layer;
17
18         function init(){
19             map = new OpenLayers.Map( $('map') );
20
21             layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
22                     "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
23
24             var control = new OpenLayers.Control();
25             OpenLayers.Util.extend(control, {
26                 draw: function () {
27                     // this Handler.Point will intercept the shift-mousedown
28                     // before Control.MouseDefault gets to see it
29                     this.point = new OpenLayers.Handler.Point( control,
30                         {"done": this.notice},
31                         {keyMask: OpenLayers.Handler.MOD_SHIFT});
32                     this.point.activate();
33                 },
34
35                 notice: function (bounds) {
36                     document.getElementById('bounds').innerHTML = bounds;
37                 }
38             });
39
40             map.addLayer(layer);
41             map.addControl(control);
42             map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
43         }
44         // -->
45     </script>
46   </head>
47   <body onload="init()">
48     <div id="map"></div>
49     <div id="bounds"></div>
50   </body>
51 </html>
Note: See TracBrowser for help on using the browser.