Dynamic points and labels
dldeskins at GMAIL.COM
dldeskins at GMAIL.COM
Mon Nov 21 13:08:14 PST 2005
I have written a function that is used place points dynamically on a map
from session variables:
function addPoints(&$map,&$image,$xCoor,$yCoor, $symbol, $text)
{
$my_layer = ms_newLayerObj($map);
$my_layer->set("name", "myLayer");
$my_layer->set("type", MS_LAYER_POINT);
$my_layer->set("status", MS_ON);
$my_layer->set(transparency, 75);
$pt = ms_newPointObj();
$ln = ms_newLineObj();
$shp = ms_newShapeObj(MS_SHAPE_POINT);
// these are pixel coordinates because TRANSFORM is FALSE
$pt->setXY($xCoor, $yCoor);
$ln->add($pt);
$shp->add($ln);
$my_class = ms_newClassObj($my_layer);
$my_class->label->set("font", "arial-bold");
$my_class->label->set("type", MS_TRUETYPE);
$my_class->label->set("size", 7);
$my_class->label->color->setRGB(255, 0 , 0);
$my_class->label->backgroundcolor->setRGB(255, 255 , 255);
$my_class->label->set("position", MS_LC);
$my_class->label->set("force", MS_TRUE);
$my_class->label->set("partials", MS_TRUE);
$my_class->label->set("buffer", 0);
$shp->set("text", stripslashes($text));
$my_style = ms_newStyleObj($my_class);
if($symbol == "g")
{
$my_style->set("symbolname","star_green");
}
elseif($symbol == "b")
{
$my_style->set("symbolname","star_blue");
}
$my_layer->addFeature($shp);
$my_layer->draw($image);
}
The symbols are showing in the proper place. The problem that I am having is
that the label will not show. Can anyone see a problem with the function? I
would eventually like to set the font, color, size dynamically also.
Thanks
More information about the MapServer-users
mailing list