Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

EDIT: solved, see working code below

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? Thank you.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

int set(string property_name, new_value)
    Set object property to a new value.

So maybe you can try with:

$layer->set('opacity', 10);
share|improve this answer
    
allright, i'll have a try in the morning! –  jorrebor Sep 17 '13 at 17:26
    
Great it works! –  jorrebor Sep 18 '13 at 7:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.