Changing symbol icon on the fly

Aaron Craig mercutio at POBOX.COM
Wed Apr 27 11:32:46 EDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Using mapscript (perl, but any generic example will do) what's the
preferred way to change the icon of a point, in a layer that is defined
as follows:

LAYER
~  NAME "musei"
~  TYPE POINT
~  STATUS OFF

~  CONNECTION 'user=tsc2 password=tsc2 dbname=geo_sardegna'
~  CONNECTIONTYPE POSTGIS
~  DATA 'the_point from musei'

~  CLASS
~    NAME "musei"
~    STYLE
~    SYMBOL
"/var/www/OpenPortal/htdocs/confartigianato/Images/icona_small.gif"
~    SIZE  10
~    COLOR 0 0 0
~  END
END


I'm doing

my $lyrPoints = $map->getLayerByName($sLayerName);

$lyrPoints->{status} = $mapscript::MS_ON;
my $cls = $lyrPoints->getClass(0); # change this if we ever use layers
with more than one class
my $stl = $cls->getStyle(0); # change this if we ever use classes with
more than one style
my $nSymbolIndex = $stl->{symbol};

my $sym = $map->{symbolset}->getSymbol($nSymbolIndex);
$sym->{imagepath} =
"/var/www/OpenPortal/htdocs/confartigianato/Images/$sLayerName.gif";

my $pnt = mapscript::pointObj->new();
$pnt->{x}       = $x;
$pnt->{y}       = $y;

$pnt->draw($map, $lyrPoints, $img, undef, $label);

but the image on the point remains the same as is declared in the mapfile.


- --
Aaron Craig
mercutio at pobox.com

===========================================================
Get Firefox!
http://www.spreadfirefox.com/?q=affiliates&id=0&t=1
===========================================================


- -=-=-
I come to wive it wealthily in Padua;
If wealthily, then happily in Padua. --The Taming of the Shrew, I:2
- -=-=-
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCb7CeoyEQRcU83p4RAlyGAJ4yVsE4Ph9zHj9L7Cpb5ZrUfDzGKACgjE5I
c4AF+i6jGSdujqmhWLcc6P8=
=QVmx
-----END PGP SIGNATURE-----



More information about the mapserver-users mailing list