[Fwd: Re: [UMN_MAPSERVER-USERS] label with mapscript]
Pietro Giannini
pgiannini at BYTEWISE.IT
Fri Jul 6 00:53:52 PDT 2007
Ciao Joerg,
Yes I'm using php_mapscript 4.10. ms_shapeObjFromWkt is more comfortable
than "create a point, create a line and add the point, create a shape and
add the line"
I think in your code you have only a label because you add only a shape to
the layer.
An annotation layer in your map file is like a points layer, then add how
many shapes than labels.
In your code you must only move the $layer->addFeature function into the
for() block:
for ($i = 0; $i < count($pointlist); $i++){
$labelpointObj->setXY(100+($i*2),100+($i*2));
$labelLineObj ->add($labelpointObj);
$labelshp = ms_newShapeObj(MS_SHAPE_POINT);
$labelshp->set("text", $pointlist[$i] );
$labelshp->add($labelLineObj);
$LabelLayerObj->addFeature($labelshp);
}
I hope it's working for you
ciao
..............................pg
--
Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E
On Gio, Luglio 5, 2007 23:52, joerg pfeiffer wrote:
> Hey Pietro,
>
> thanks for your help. It seems my mapscript version is not up to date,
> so it doesn't know the ms_shapeObjFromWkt function. But I got it working
> with the following code. Only problem: It only prints one label, not as
> many labels, as I have in the array:
>
> $LabelLayerObj = $this->map->getLayerByName($layername);
> $labelpointObj = ms_newPointObj();
> $labelLineObj = ms_newLineObj();
>
> for ($i = 0; $i < count($pointlist); $i++){
>
> $labelpointObj->setXY(100+($i*2),100+($i*2));
> $labelLineObj ->add($labelpointObj);
> $labelshp = ms_newShapeObj(MS_SHAPE_POINT);
> $labelshp->set("text", $pointlist[$i] );
> $labelshp->add($labelLineObj);
> }
>
> $LabelLayerObj->addFeature($labelshp);
>
> So if I know how to print more than one label, I would be very happy! :-)
>
> cheers
> Joerg
>
>
>
>
>
>
> pgiannini at bytewise.it schrieb:
>> 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