Perl Mapscript Problem

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Tue Sep 13 21:09:41 EDT 2005


Hi All,

I had dynamic symbol manipulation working on MS 4.01 but can not get it 
to work on 4.4.1 or 4.6.1. In the following code snippets every think 
works with the default symbol that is defined in symbolset file, but the 
code does not let me change the imagepath on the fly.

Also, I can not get the label on the umarker layer to show unless I 
specify     LABELCACHE FALSE    and umarker layer is the last in the 
mapfile.

Any ideas or help would be appreciated.

-Steve W.


 From the mapscript:

     my $lay = $mapObj->getLayerByName('umarker');
     if ($lay) {
         $lay->{status} = 1;
         my $class = $lay->getClass(0);
         my $pnt = new mapscript::pointObj();
         my @marks = split(/;/, $mark);
         foreach my $x (@marks) {
             my ($y, $x, $txt, $sym) = split(/[\s,]/, $x);
             if ($sym && -r "$symbol_path/$sym") {
                 my $style = $class->getStyle(0);
                 $style->{symbolname} = "$symbol_path/$sym";
             }
             $pnt->{x} = $x;
             $pnt->{y} = $y;
             $pnt->draw($mapObj, $lay, $imgObj, 0, $txt);
         }
     }

Or alternately from mapscript:

     my $lay = $mapObj->getLayerByName('umarker');
     if ($lay) {
         $lay->{status} = 1;
         my $pnt = new mapscript::pointObj();
         my @marks = split(/;/, $mark);
         my $symbolset = $mapObj->{symbolset};
         my $symbol = $symbolset->getSymbolByName('marker');
         foreach my $x (@marks) {
             my ($y, $x, $txt, $sym) = split(/[\s,]/, $x);
             if ($sym && -r "$symbol_path/$sym") {
                 $symbol->{imagepath} = "$symbol_path/$sym";
             }
             $pnt->{x} = $x;
             $pnt->{y} = $y;
             $pnt->draw($mapObj, $lay, $imgObj, 0, $txt);
         }
     }



 From the mapfile:

   LAYER
     NAME "umarker"
     STATUS ON
     TYPE POINT
     LABELCACHE FALSE
     TEMPLATE "ttt.html"
     CLASS
       NAME "User Marker"
       #TEXT "HERE"
       SYMBOL "marker"
       COLOR 0 0 0
       LABEL
         TYPE TRUETYPE
         FONT "arial-bold"
         SIZE 8
         POSITION AUTO
         OFFSET 0 0
         BUFFER 4
         COLOR 0 0 0
         OUTLINECOLOR 230 230 230
         FORCE TRUE
       END
     END
   END

 From the symbol.sym symbolset file:

   Symbol
     Name 'marker'
     Type PIXMAP
     Image 'markers/purppin.png'
     Transparent 1
   END



More information about the mapserver-users mailing list