OpenLayers OpenLayers

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

Revision 3369, 1.5 kB (checked in by euzuro, 1 year ago)

the map object takes care of getting the element from the id. no need to be doing this out here.... this in an effort to minimize the use of , which we were trying to phase out.

  • Property svn:eol-style set to native
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             layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
21                     "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
22            
23             var control = new OpenLayers.Control();
24             OpenLayers.Util.extend(control, {
25                 draw: function () {
26                     // this Handler.Box will intercept the shift-mousedown
27                     // before Control.MouseDefault gets to see it
28                     this.box = new OpenLayers.Handler.Box( control,
29                         {"done": this.notice},
30                         {keyMask: OpenLayers.Handler.MOD_SHIFT});
31                     this.box.activate();
32                 },
33
34                 notice: function (bounds) {
35                     alert(bounds);
36                 }
37             });
38
39             map.addLayer(layer);
40             map.addControl(control);
41             map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
42         }
43         // -->
44     </script>
45   </head>
46   <body onload="init()">
47     <div id="map"></div>
48   </body>
49 </html>
Note: See TracBrowser for help on using the browser.