[OpenLayers-Dev] ScaleLine on IE
Tim Schaub
tschaub at opengeo.org
Tue Mar 10 12:04:23 EDT 2009
Hey-
Andrea Battisti wrote:
> Hi All,
>
>
> there is a small glitch on the ScaleLine Control:
> http://dev.openlayers.org/releases/OpenLayers-2.7/lib/OpenLayers/Control/ScaleLine.js
>
Thanks for the information. This looks to be a decent solution to a
real problem. Please create a ticket and include all information
required to duplicate (and fix) the issue if possible.
http://trac.openlayers.org/wiki/FilingTickets
Thanks,
Tim
> 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,
>
--
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.
More information about the Dev
mailing list