[OpenLayers-Users] Scale Bar

Tim Schaub noreply at geocartic.com
Fri Aug 11 11:27:21 CDT 2006


Hey John-

> > I've put together a scale bar for open layers. See it in 
> action here:
> > http://tools.geocartic.com/scalebar/openlayers.html
> 
> pretty.
> 
> 
> > This can be configured in javascript and styled up in css. I'll be 
> > making some modifications over the next couple days.
> 
> Will one be able to set the font to, say, Verdana?

/* currently declared in scalebar.css */
.sbWrapper {
    font-family: Verdana;
}

> Will one be able to set the units of measurement?

/* assuming myScaleBar = new OpenLayers.Control.ScaleBar() */
myScaleBar.displaySystem = 'english'; // or metric currently


> Will one be able to set the position 

/* more css */
div.sbContainer {
    position: absolute;
    bottom: 10px;
}

> and pixel size of the scalbar?

/* you can configure scale bar pixel size range */ 
myScaleBar.minWidth = 150;
myScaleBar.maxWidth = 200;
/* scale bar elements are "sized" (styled) in css */

> How are you computing the average scale for the map?  You 
> might want to use the new scaled-based methods that just got 
> added to SVN head.

/* in the method to update the scale bar */
var res = this.map.getResolution();
this.scaleDenominator = res * this.INCHES_PER_UNIT[this.units] * this.dpi;

> 
> 
> Thanks!
> 
> John
> 

Don't know if I've found the new scale-based methods.  I'll poke around
more.

Tim

> 



More information about the Users mailing list