label with mapscript

Pietro Giannini pgiannini at BYTEWISE.IT
Thu Jul 5 10:16:16 EDT 2007


Hi Joerg,

try:

	$oMap = ms_newMapObj("your.map");
	// obtain the layer object:
	$oLay = $oMap->getLayerByName("citylabels");
	// obtain a shape object with the fields of a form (in this case they are
named 'X' and 'Y'):
	$oShape = ms_shapeObjFromWkt("POINT(".$_REQUEST['X']."
".$_REQUEST['Y'].")");
	// set the text property of the shape object:
	$oShape->set("text","ciao");
	// add the shape to the layer:
	$oLay->addFeature($oShape);
	// draw the map:
	$oImage = $oMap->draw();
	$mapImage_url = $oImage->saveWebImage();

I tried and it works well.
You can create how many features you want.
Hope it is useful...

ciao
.............................pg




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




> Hello,
>
> I have this simple layer:
> LAYER
> 	NAME "citylabels"
> 	STATUS DEFAULT
> 	TRANSFORM FALSE
> 	TYPE ANNOTATION
> 	FEATURE
> 		POINTS
> 			200 150
> 		END
> 		TEXT 'Hello world.  Mapserver rocks.'
> 	END
> 	CLASS
> 		LABEL
> 			TYPE BITMAP
> 			COLOR 0 0 0
> 		END
> 	END
> END
>
> and would like to set the place and the text dynamically with
> php-mapscript.
> Does anybody have a simple codesnippet?
>
> best regrads
> Joerg
>


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



More information about the mapserver-users mailing list