[mapserver-users] [Scalebar] Wrong values

Steve Lime Steve.Lime at dnr.state.mn.us
Fri Jul 11 16:10:01 EDT 2008


Unfortunately MapServer only supports 1 scalebar object so you're kinda
stuck unless you
change things from your interface. For example, you could get at the
scale in a templated
interface via the [scale] tag and with a little javascript you could
change the UNITS parameter
for the scalebar. Something like this (assumes MapServer 5.0+) in your
template:

<script language=javascript>
function updateScalebar(img) {
  var scale = [scale];
  var units;

  if(scale < 10000)
    units = 'CENTIMETERS'; # does MapServer support centimeters?
  elsif (scale < 10000)
    units = 'METERS';
  else
    units = 'KILOMETERS';

  img.src =
'/cgi-bin/mapserv?map=[map]&mapext=0+0+[maxx]+[maxy]&mapwidth=[mapwidth]+[mapheight]';
}
</script>

and then add a call to updateScalebar() to your onload method, passing
a reference to the image
used to display the scalebar.

A similar technique would work with other clients.

The idea of supporting multiple scalebars with MIN/MAX scale
denominators is interesting though. I'll file a
ticket so it doesn't get lost...

Steve 

>>> On 7/10/2008 at 4:28 AM, in message
<4875D63A.2060401 at wowcompany.com>, Fabian
Rami <fabian.rami at wowcompany.com> wrote:
> Fabian Rami a écrit :
>> Hi everyone,
>>
>> I have a mistake with the scalebar.
>> When i use the demo with my mapfile i have meters for europe level
,
>> centimeters for country level and kilometers for street level.
>>
>> I still a beginner with MapServer so if you see something wrong
>> please tell me :)
>>
>> I use Teleatlas data, i have found the specification of the data :
>> Projection: Geographic (not projected)
>> Datum WGS84 (labeled GCS_WGS_1984 in ESRI products)
>> Paramaters:
>> ●GEOGCS["GCS_WGS_1984",
>> ●DATUM["D_WGS_1984",
>> ●SPHEROID["WGS_1984",6378137,298.257223563]],
>> ●PRIMEM["Greenwich",0],
>> ●UNIT["Degree",0.017453292519943295]]
>>
>>
>> THANKS FOR YOUR HELP :o)
>>
>>
> Hummm, i found that the minscale mapscale used to draw the map is the

> reason of the error.
> 
> How can i know the good value to put in minscale, maxscale for having
a 
> correct behavior at the scalebar ?
> for example :
> Before with 65 at the top scale we have a graduation  in meters ( +/-
0 
> to 80 )
> Now with  65.000.000 at the top scale we have a graduation in
kilometers 
> ( 0 to 4500)
> 
> How know how to set this value correctly ?
> 
> 
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org 
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the mapserver-users mailing list