How can I set attribute values of a layer object with MapScript?
I'm using MapServer version 5.0.3, the php_mapscript.so lib is loaded in my app context
I have a simple Mapfile:
MAP
SIZE 500 500
EXTENT -180 -90 180 90
UNITS dd
CONFIG "CPL_DEBUG" "ON"
CONFIG "MS_ERRORFILE" "/var/www/Data/Data/mapserver/mapserver.log"
SYMBOLSET "/var/www/Data/Data/mapserver/symbols.sym"
FONTSET "/var/www/Data/Data/mapserver/fontset.txt"
#--------------------------------------------------------------------------------
# load lines
#--------------------------------------------------------------------------------
LAYER
NAME "loadlines"
TYPE POLYGON
DATA "/var/www/Data/Data/mapserver/data/loadlines/loadlines.shp"
STATUS ON
OPACITY 100
DEBUG 5
CLASS #default coloring
STYLE
COLOR 0 0 0
WIDTH 6
#PATTERN 40 10 END
END
NAME "gust"
OUTLINECOLOR 254 254 254
COLOR 100 100 100
#OPACITY 50
END
TEMPLATE "blank.html"
DUMP TRUE # allow GML export
PROJECTION
"init=epsg:4326"
END
METADATA
"wms_title" "ffg_test"
"wms_srs" "EPSG:54004 EPSG:4269 EPSG:4326"
END
END
END
Which I want to view by calling this PHP script:
<?php
$map_path="/var/www/Data/Data/mapserver/routeguardTemp/test/";
$map = ms_newMapObj($map_path."loadlines.map");
$layer = $map->getLayerByName('loadlines');
$layer->set('opacity', 10);
$image=$map->draw();
$image_url=$image->saveWebImage();
?>
<HTML>
<HEAD>
<TITLE>Map</TITLE>
</HEAD>
<BODY>
<IMG SRC=<?php echo $image_url; ?> >
</BODY>
</HTML>
The script should alter the opacity value of the layer, but there is no effect.
How can I do this?
Best Answer
Not sure about the old version of mapscript, the documentation is not available anymore. But for the latest version of PHP mapscript, the property of layer object is set via 'set' method.
So maybe you can try with: