]> dev.renevier.net Git - syp.git/blob - openlayers/tests/Control/Scale.html
fixes notices
[syp.git] / openlayers / tests / Control / Scale.html
1 <html>
2 <head>
3   <script src="../../lib/OpenLayers.js"></script>
4   <script type="text/javascript">
5     var map; 
6     function test_Control_Scale_constructor (t) {
7         t.plan( 2 );
8     
9         control = new OpenLayers.Control.Scale();
10         t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
11         t.eq( control.displayClass,  "olControlScale", "displayClass is correct" );
12     }
13     function test_Control_Scale_initwithelem (t) {
14         t.plan( 1 );
15     
16         control = new OpenLayers.Control.Scale(OpenLayers.Util.getElement('scale'));
17         t.ok(true, "If this happens, then we passed. (FF throws an error above otherwise)");
18     }
19     function test_Control_Scale_updateScale (t) {
20         t.plan( 4 );
21     
22         control = new OpenLayers.Control.Scale('scale');
23         t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
24         map = new OpenLayers.Map('map');
25         layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
26         map.addLayer(layer);
27         map.zoomTo(0);
28         map.addControl(control);
29         t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default."  );
30         map.zoomIn();
31         t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 221M", "Zooming in changes scale"  );
32         map.baseLayer.resolutions = [OpenLayers.Util.getResolutionFromScale(110)];
33         map.zoomTo(0);
34         t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded"  );
35     }
36     function test_Control_Scale_internalScale (t) {
37         t.plan(2);
38         control = new OpenLayers.Control.Scale();
39         t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
40         map = new OpenLayers.Map('map');
41         layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
42         map.addLayer(layer);
43         map.zoomTo(0);
44         map.addControl(control);
45         t.eq(control.div.firstChild.innerHTML, "Scale = 1 : 443M", "Internal scale displayed properly.");
46     }    
47   </script>
48 </head>
49 <body>
50     <a id="scale" href="">Scale</a> <br />
51     <div id="map" style="width: 1024px; height: 512px;"/>
52 </body>
53 </html>