[Mapserver-users] php mapscript ms_newLayerObject and no mapfile

aaronkoning at shaw.ca aaronkoning at shaw.ca
Sun Dec 14 07:10:19 EST 2003


Hi List,

I am trying to use mapserver without a mapfile and my methodology was to use the europe example provided for MapScript and remove pieces from the mapfile and add equivalent code with mapscript. I started removing the style variables and then the class variables with success, until I got to the layer (object) variables. When I removed the mapfile layer variables (commented out below) and entered equivalent MapScript code the image that is produced is blank/empty. I believe the problem may be with ms_newLayerObj, although there are no syntax errors. I could simply add a null layer in the mapfile and use getLayerByName, as suggested in other posts, but my goal is to eliminate the need for the mapfile. Code is below:

Thanks,
Aaron

-----MAPFILE----------------

NAME FIRSTMAP
SIZE 400 400
STATUS ON
EXTENT -5696501 1923039 5696501 11022882
UNITS METERS
SHAPEPATH "./"

WEB
IMAGEPATH "/var/www/html/test/mapscript/t/tmp/"
IMAGEURL "/test/mapscript/t/tmp/"
END

#LAYER
#NAME world
#TYPE POLYGON
#STATUS ON
#DATA europe
#END

END

-----HTML/MAPSCRIPT---------

<?php

dl('php_mapscript.so');

$map_path="/var/www/html/test/mapscript/t/";
$map = ms_newMapObj($map_path."europe.map");

$layer = ms_newLayerObj($map);
$layer->set("name","world");
$layer->set("type","MS_LAYER_POLYGON");
$layer->set("status","MS_ON");
$layer->set("data","europe");

//$layer = $map->getLayerByName("world");
$class = ms_newClassObj($layer);

$style = ms_newStyleObj($class);
$style->outlinecolor->setRGB(1,1,111);
$style->color->setRGB(111,211,211);

$image=$map->draw();
$image_url=$image->saveWebImage("MS_PNG",1,1,0);

?>
<HTML>
<HEAD>
<TITLE>Map 1</TITLE>
</HEAD>
<BODY>
<center>
<TABLE>
<TR><td>
<INPUT TYPE=IMaGe name=mapa src="<?php echo $image_url; ?>">
</td></TR>
</TABLE>
<center>
</BODY>
</HMTL>

-----------END--------------






More information about the mapserver-users mailing list