[Cartoweb-users] Dynamic labels

Knut Staring knutst at gmail.com
Thu Mar 23 01:49:21 EST 2006


Hello list,

I have several data time series associated with geographic coordinates
(points). I would like to display these values in the right locations
according to user selection of a) what data they would like to see, and b)
for which period. Of course, if it was just a few datasets and only one
period, I could just statically add some attribute columns to a point
shapefile and use a label to display, but it needs to be more dynamic than
that, i.e. the labels must be created and displayed on the fly, with the
values coming from another database table.

I would be very grateful for any pointers to how to best approach this,
whether by extending some existing features of CartoWeb, or "from scratch"
in a plugin using PHP mapscript.

Should I create a shapefile object, or use the coordinates to add inline
features to a  (new or existing) layer?

My first thoughts were along the following lines, but I'm not getting it to
display, and not sure how to proceed.

$msMapObj = $this->serverContext->getMapObj();
$pointLayer = ms_newLayerObj($msMapObj);
$pointLayer ->set('type', MS_LAYER_POINT);
// get $x and $y and the $value for this point
$newPoint = ms_shapeObjFromWkt("POINT ($x $y)");
$newPoint->set("text","$value");
$pointLayer->addFeature($newPoint);

$msClass = ms_newClassObj($pointLayer);
$msClass->label->set("type", "TRUETYPE");
$msClass->label->set("font", "Vera");
$msClass->label->set("size", 6);
$msClass->label->color->setRGB(0,0,0);

Thanks for any suggestions,
Knut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20060323/339a1242/attachment.html


More information about the Cartoweb-users mailing list