1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>Custom Control Example</title>
4 <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
5 <link rel="stylesheet" href="style.css" type="text/css" />
6 <script src="../lib/OpenLayers.js"></script>
7 <script type="text/javascript">
14 map = new OpenLayers.Map('map');
15 layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
16 "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
18 var control = new OpenLayers.Control();
19 OpenLayers.Util.extend(control, {
21 // this Handler.Box will intercept the shift-mousedown
22 // before Control.MouseDefault gets to see it
23 this.box = new OpenLayers.Handler.Box( control,
24 {"done": this.notice},
25 {keyMask: OpenLayers.Handler.MOD_SHIFT});
29 notice: function (bounds) {
30 var ll = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.left, bounds.bottom));
31 var ur = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.right, bounds.top));
32 alert(ll.lon.toFixed(4) + ", " +
33 ll.lat.toFixed(4) + ", " +
34 ur.lon.toFixed(4) + ", " +
40 map.addControl(control);
41 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
45 <body onload="init()">
46 <h1 id="title">Custom Control Example</h1>
52 Demonstrate the addition of a draggable rectangle to the OpenLayers window.
55 <div id="map" class="smallmap"></div>