[Mapserver-users] Re: html-type legends with perl mapscript

pkishor_98 pkishor at geoanalytics.com
Mon May 26 23:34:12 EDT 2003


the perl/mapscript docs are misleading (well, I got misled). The docs
mention --

createLegendIcon(mapObj, layerObj, width, height);
drawLegendIcon(mapObj, layerObj, width, height, dstImage, dstX, dstY);

Note that the drawLeg command should be

drawLegendIcon(mapObj, layerObj, width, height, imgObj, dstX, dstY);

Now, here is what all this means...

# for a layer $layerObj, grab the class
my $classObj = $layerObj->getClass(0);
# create an image object for the legend. 30 and 25 are the 
# width and height of my legend
my $imgObj = $classObj->createLegendIcon($mapObj, $layerObj, 30, 25);
# now draw the legend icon... my icon is anchored at 0,0
$classObj->drawLegendIcon($mapObj, $layerObj, 30, 25, $imgObj, 0, 0);
# save the image
$img->saveImage( $image, 
                              $mapscript::MS_PNG, 
                              $mapObj->{interlace}, 
                              $mapObj->{transparent}, 
                              $mapObj->{imagequality} );

to create for many layers or classes, iterate accordingly. I will put
a complete example 
in the wiki at some point.

--- In mapserver-users at yahoogroups.com, "pkishor_98" <pkishor at g...>
wrote:
> --- In mapserver-users at yahoogroups.com, Daniel Morissette
<morissette at d...> 
> wrote:
> > In PHP MapScript there is a $class->drawLegendIcon() that you
could use
> > for this.  I don't know if it's been made available in Perl
MapScript,
> 
> ah yes, class->drawLegendIcon. It is there; I just was looking at
the most intuitive 
(to 
> me) but wrong place.
> 
> Thanks Daniel for setting me straight.
> 
> Puneet.
> 
> 
> 
> 
> > but if not then you could perhaps file this as an enhancement bug.
> > 
> > Daniel
> > 
> > pkishor_98 wrote:
> > > 
> > > to the perl wonks...
> > > 
> > > the legendObj seems pretty sparse in the methods it offers...
are there
> > > any undocumented tricks to create, say, only the keybox for a
specific layer 
> (without
> > > the name of the layer, etc.), or do I have to do implement some
kludge -- I 
was
> > > thinking of turning on one layer at a time, creating legends,
writing them to 
> separate
> > > image files, and then reading them all in... but I would get
the little legend 
> keybox as
> > > well as the layer name... any ideas?
> > > 
> > > thanks.
> > >




More information about the mapserver-users mailing list