[ka-Map-users] Scalebar

Tim Schaub tim at commenspace.org
Thu Apr 20 13:26:04 EDT 2006


Hey Ramesh-

> but because the map has zoomed in, the length of the scale is 
> double that of previous zoom level!
> 
> This is basically correct but the length of the line drawn is 
> doubled and I am wondering if there is anyway the scales can become

Sounds like the scale bar is still displaying the correct scale, it's
just longer than you'd like.  You can change this behavior by modifying
the minWidth and maxWidth properties.  This is done wherever you
initialize your scale bar (in startUp.js if you use the index.html from
CVS - note that I just updated startUp.js to use the correct property
names).

So, if you want to force the scale bar to a narrower range of widths, do
something like:
    myScalebar.minWidth = 150;
    myScalebar.maxWidth = 200;

(This will force the scale bar to remain between 150 and 200 pixels
wide.)

The reason there is a range of widths is so that scale bar subdivisions
can be calculated that fall on nice looking numbers (I think 0.5 is
nicer than 0.25 for example).  If you give it a very narrow range of
widths, you might find some scale levels that produce gnarly subdivision
widths (in display units).

If you want to play around with modifying the scale bar, you can use 
http://mapserver.commenspace.org/tools/scalebar/

All the javascript that you'll need (for non-default configuration) is
displayed in the box on the lower right.

Tim



More information about the ka-Map-users mailing list