[Mapserver-users] help with adding labels/annotation, please
Haiyan Liu
hliu at jdbarnes.com
Tue Apr 13 10:22:31 PDT 2004
Hi all,
I had some problem with adding annotation to my map. I wrapped some
codes(see Dylan Keon's posting) posted in this list into my function(see
below). I created the map file. But what I got is just a blank image.
Can anyone tell me what is going wrong in my situation? Thanks.
// draw annotation on passed in image
// @param: float $x, $y
// @param: string $layer_name -- annotation layer name
// @param: string $text -- for label
// $param: reference of imageObj $image
function addLabel($x, $y, $layer_name, $text, &$image){
$pt = ms_newLineObj();
$pt->addXY($x, $y);
$shape = ms_newShapeObj(MS_SHAPE_LINE);
$shape->set('classindex', 0);
$shape->set('text', $text); // assign the label
$shape->add($pt);
// note: $map is a member var in my map class
$layer = $this->map->getLayerByName($layer_name);
$layer->set("status", 1);
$layer->addFeature($shape);
$layer->draw($image);
//$shape->draw($this->map, $layer, $image);
$pt->free();
$shape->free();
}
#=============================================
LAYER
NAME pin_text
STATUS ON
TYPE ANNOTATION
FEATURE
END
CLASS
LABEL
TYPE TRUETYPE
FONT arial
SIZE 10
COLOR 250 0 0
POSITION UC
FORCE TRUE
END
END
END
#=============================================
More information about the MapServer-users
mailing list