[mapserver-users] Drawing a simple filled polygon with PHP/mapscript

Pietro Giannini pgiannini at bytewise.it
Wed Mar 11 05:55:33 EDT 2009


Hi indieaz,

add:
$layer->set("type",MS_LAYER_POLYGON);
$layer->set("status",MS_DEFAULT);  



indieaz ha scritto:
> Been doing a lot of tinkering, have been plotting points on maps with variety
> of shapes from database sources etc.  However, I'm now against what I
> believe should be an extremely simple problem.
>
> I have a set of coordinates (max lat/long and min lat/long) that make up a
> rectangle I need to plot onto my map.  I'm pulling my hair out...I get a
> .png image out, but it's empty.  Here's an example of the code I'm trying to
> use:
>
> $map = ms_newMapObj();
> $layer = ms_newLayerObj($map);
> $polygon= ms_newShapeObj(MS_SHAPE_POLYGON);
> $polyLine = ms_newLineObj();
> $polyLine->addXY(60,60);
> $polyLine->addXY(75,60);
> $polyLine->addXY(75,75);
> $polyLine->addXY(60,75);
> $polyLine->addXY(60,60);
> $polygon->add($polyLine);
>
> $Class = ms_newClassObj($layer);
> $Class->set( "name","MyClass");
> // Create a style object defining how to draw features
> $lineStyle = ms_newStyleObj($Class);
> $lineStyle->color->setRGB(255,255,0);
>
>
> and my .map file:
>
> MAP
>
>   STATUS ON
>   SIZE 600 400
>   IMAGECOLOR 255 255 255
>   IMAGETYPE PNG
>   extent -180 -90 180 90
>   PROJECTION
>     "init=epsg:4326"
>   END
>
> END
>   


-- 
Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E



More information about the mapserver-users mailing list