[OpenLayers-Dev] ScaleLine on IE
Andrea Battisti
battisti at actgate.com
Tue Mar 10 11:49:26 EDT 2009
Hi All,
there is a small glitch on the ScaleLine Control:
http://dev.openlayers.org/releases/OpenLayers-2.7/lib/OpenLayers/Control/ScaleLine.js
The "update" function computes the width of the scale element without
checking if the element is visible.
/* works */
scaleControl = new OpenLayers.Control.ScaleLine();
/* triggers a runtime error on IE (tried on IE 6, 7 and 8) */
scaleControl = new OpenLayers.Control.ScaleLine( { bottomOutUnits: "",
bottomInUnits: "" } );
A simple workaround would be to compute the top and bottom elements
width only if they are visible:
topPx = 0; bottomPx = 0;
if ( this.eTop.style.visibility == "visible" )
{
var topMax = maxSizeData / inches[topUnits];
// and to map units units
var topRounded = this.getBarLen(topMax);
// now trim this down to useful block length
topMax = topRounded / inches[curMapUnits] *
inches[topUnits]; // and back to display units
topPx = topMax / res;
// and to pixel units
}
if ( this.eBottom.style.visibility == "visible" )
{
var bottomMax = maxSizeData / inches[bottomUnits];
// and to map units units
var bottomRounded = this.getBarLen(bottomMax);
// now trim this down to useful block length
bottomMax = bottomRounded / inches[curMapUnits] *
inches[bottomUnits]; // and back to display units
bottomPx = bottomMax / res;
// and to pixel units
}
Best Regards,
--
Andrea Battisti
Applied Coherent Technology Corp.
More information about the Dev
mailing list