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

pkishor_98 pkishor at geoanalytics.com
Mon May 26 22:00:43 PDT 2003


Cripes... I am holding a conversation with myself, correcting and wronging myself. 
Now, I have come to the conclusion that I wrote nonsense below... 

so, to those who know... please, what is the difference between createLegendIcon and 
drawLegendIcon?

I want to draw a separate legend icon for each layer, but if a layer has a more than 
one classes, I would like to be able to draw a single image file with icons for all the 
classes... 

Many tia,

Puneet.


--- In mapserver-users at yahoogroups.com, "pkishor_98" <pkishor at g...> wrote:
> 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.
> > > >
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at l...
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the MapServer-users mailing list