[mapserver-users] PHP layer->updateFromString problem setting type and symbol name

Joe Franklin traderboy at yahoo.com
Thu Jan 21 18:04:59 PST 2010


I really like the updateFromString functions in Mapserver Mapscript.  I've
eliminated my .map files, instead storing the layer definitions in a database and drawing them on-demand using PHP.  However, I've found a few values ($layer->type and $style->symbolname) that aren't correctly set using Mapserver 5.6.1 (also tried 5.4.2).  Here's an example:

<?php
$mapDef="MAP
NAME 'test'
SIZE 400 400
EXTENT 0 0 100 100
END
";

$layerDef="LAYER
NAME 'Airports'
STATUS ON
TYPE point
FEATURE POINTS 10 10 50 50 1 50 70 10 END END
CLASS
STYLE
SYMBOL 'airport.gif'
END
END
END";

$oMap = ms_newMapObjFromString($mapDef);
$oLayer=ms_newLayerObj($oMap);
$oLayer->updateFromString($layerDef);
//First problem: returns -1
//echo $oLayer->type;
//$oLayer->set("type",MS_LAYER_POINT);

//Second problem is that the symbol gif isn't used
//unless it is explicitly set again below
//$cls = $oLayer->getClass(0);
//$style = $cls->getStyle(0);
//if($style->symbolname!='')$style->set("symbolname",$style->symbolname);
$oMap->selectOutputFormat('gif');
$img = $oMap->draw();
$img->saveImage("output.gif");
?>


      



More information about the MapServer-users mailing list