problems creating a new layerObj

Robert Chavez rchavez at perseus.tufts.edu
Tue Oct 17 11:10:33 EDT 2000


Greetings,

I'm having some problems creating a new layer for my mapfile using
mapscript.  I'm trying to create a separate labeled layer for each object
selected by a user from a menu in my map interface, in this case the
objects are buildings.  I've narrowed the problem down to the way I'm
constructing the new layer -- I seems to be doing something wrong
here.

I wrote a dummy mapfile for this layer with all the same parameters to
make sure the expression and data were OK and the layer drew just fine.
But, trying to build it from the script doesn't work at all. Here's the
Perl code, most of the field values are generated elswhere in the script
so I'll fill in a sample here.

<snip>

#build the layer	
$layer = new layerObj($map);
$layer->{name} = $newlayername;  #$new layername = leis0
$layer->{type} = $mapscript::MS_POLYGON;
$layer->{status} = $mapscript::MS_ON;
$layer->{data} = $dataname; #$dataname = blg_leis
$layer->{classitem} = $itemname; #$itemname = "NAME"
$class = new classObj($layer);
$class->setExpression($the_expression); #$the_expression = "Buckingham
Palace"
$class->{symbol} = 0;
$class->{color} = $map->addColor(255,204,0);
		
#draw it
$layer->draw($map, $img);

#go on and add more static layers then call &mapscript::msSaveImage($img,
$image_path . $image_id, 1,1);
</snip>

Any advice would be greatly appreciated.

Thanks,
Rob Chavez
Programmer
The Perseus Project
rchavez at perseus.tufts.edu




More information about the mapserver-users mailing list