[mapserver-users] MapScript scalebar and reference map

Dylan Keon keon at nacse.org
Thu Feb 6 22:30:55 EST 2003


wendyandtony wrote:
 >
 > I have built a basic Perl MapScript interface by adapting the
 > mapquakes.pl example and using my own data. Now I'd like to add a
 > scalebar and reference map, but don't know where to begin. I've been
 > through the archives several times and there is next to nothing on
 > this subject. The actual Perl MapScript reference is not much use
 > either - both these topics lack any example code.
 >
 > Would anyone be able to point me in the right direction, or be
 > willing to share an example?


One way is to just define the reference map and scalebar in your 
mapfile.  See the mapfile documentation for specific info.  You also 
need to create a base image for the reference map...to do this, create a 
simple mapfile with whatever layers you want visible, but set the size 
to something small (like SIZE 120 120, for example).  Then run shp2img 
against that mapfile to create your base image for the reference map 
(like this: shp2img -m ref.map -o ref.png).

You can then generate and reference each image the same way you do with 
your map image.  Here's an example (PHP):

// render scalebar
$scale_img = $map->drawScaleBar();
$scale_url = $scale_img->saveWebImage();

// render reference map
$ref_img = $map->drawReferenceMap();
$ref_url = $ref_img->saveWebImage();


--Dylan




More information about the mapserver-users mailing list