diff --git a/lib/OpenLayers/Control/ScaleLine.js b/lib/OpenLayers/Control/ScaleLine.js index e29256b2b9..432dd66b41 100644 --- a/lib/OpenLayers/Control/ScaleLine.js +++ b/lib/OpenLayers/Control/ScaleLine.js @@ -189,12 +189,18 @@ OpenLayers.Control.ScaleLine = OpenLayers.Class(OpenLayers.Control, { var bottomPx = bottomMax / res; // now set the pixel widths - this.eTop.style.width = Math.round(topPx) + "px"; - this.eBottom.style.width = Math.round(bottomPx) + "px"; - // and the values inside them - this.eTop.innerHTML = topRounded + " " + topUnits; - this.eBottom.innerHTML = bottomRounded + " " + bottomUnits ; + + if (this.eBottom.style.visibility == "visible"){ + this.eBottom.style.width = Math.round(bottomPx) + "px"; + this.eBottom.innerHTML = bottomRounded + " " + bottomUnits ; + } + + if (this.eTop.style.visibility == "visible"){ + this.eTop.style.width = Math.round(topPx) + "px"; + this.eTop.innerHTML = topRounded + " " + topUnits; + } + }, CLASS_NAME: "OpenLayers.Control.ScaleLine" diff --git a/tests/Control/ScaleLine.html b/tests/Control/ScaleLine.html index a560cf9721..7d4968fec4 100644 --- a/tests/Control/ScaleLine.html +++ b/tests/Control/ScaleLine.html @@ -168,6 +168,18 @@ map.destroy(); } + function test_ie_oneunit(t) { + t.plan(2); + var control = new OpenLayers.Control.ScaleLine({bottomOutUnits:'',bottomInUnits:'',maxWidth:150}); + t.ok(control instanceof OpenLayers.Control.ScaleLine, "new OpenLayers.Control returns object" ); + var map = new OpenLayers.Map('map'); + var layer = new OpenLayers.Layer.WMS('Test Layer', "bogus", {}); + map.addLayer(layer); + map.zoomTo(0); + map.addControl(control); + t.ok(true, "invisible bottom scale doesn't cause scaleline failure (IE only)"); + map.destroy(); + }