3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_Control_Scale_constructor (t) {
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" );
13 function test_Control_Scale_initwithelem (t) {
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)");
19 function test_Control_Scale_updateScale (t) {
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'});
28 map.addControl(control);
29 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default." );
31 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 221M", "Zooming in changes scale" );
32 map.baseLayer.resolutions = [OpenLayers.Util.getResolutionFromScale(110)];
34 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded" );
36 function test_Control_Scale_internalScale (t) {
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'});
44 map.addControl(control);
45 t.eq(control.div.firstChild.innerHTML, "Scale = 1 : 443M", "Internal scale displayed properly.");
50 <a id="scale" href="">Scale</a> <br />
51 <div id="map" style="width: 1024px; height: 512px;"/>