[ka-Map-users] Hiding the scalebar
dbadke at uvic.ca
Wed Jan 25 17:23:35 EST 2006
A while ago I asked about being able to hide the scalebar while still
displaying the legend, and doing this for some but not all maps.
I have now modified the code to do this; with the mods below, ka-Map
will obey the SCALEBAR STATUS setting in the map file, allowing the
scalebar to be turned on or off for individual maps. I am posting the
code in case anyone else has a similar requirement. No guarantees, only
tested in Firefox, and if anyone has a better way, let me know!
(Something similar could also be done for LEGEND STATUS.)
This all only applies to the CVS version of ka-Map. If you have modified
the 'reference' section in index.html (or equivalent) or the screen.css
file, you will have to adjust this code. Note that if there is no
SCALEBAR section in the map file, MapServer assumes the STATUS is OFF.
1. In init.php, just before the $szResult .= "this.addMap( map );"; line
(around 261), add these lines:
$show_scale = 'true';
if ($oMap->scalebar->status == MS_OFF)
$show_scale = 'false';
$szResult .= "map.showScalebar = " . $show_scale . ';';
This passes the SCALEBAR STATUS setting from the map file to a new
element in the _map object.
2. In kaMap.js, in the _map object constructor (around line 1888), add
this.showScalebar = true;
By default, the scalebar will be visible.
3. In startUp.js, in the myMapInitialized function, add these lines (I
put them near the end of the function; probably doesn't matter):
getObject('scaleReference').display = 'none';
getObject('refToggler').bottom = '153px';
getObject('reference').height = '150px';
getObject('scaleReference').display = 'block';
getObject('refToggler').bottom = '213px';
getObject('reference').height = '210px';
This sets the visibility of the whole 'scaleReference' div, and adjusts
the CSS of the 'reference' and 'refToggler' divs so the legend is still
at the bottom of the window.
4. The scalebar div is displayed before this code can be executed, so
the div is initially visible and then vanishes. If you want it to not do
that, add a 'display: none' line to the scaleReference style in
screen.css; the div will then be initially hidden but will appear if the
SCALEBAR STATUS is ON.
More information about the ka-Map-users