Dynamic map title
Stefanie Weykam
sweykam at TELELINE.ES
Thu Aug 26 12:16:02 PDT 2004
I think I am getting closer (thanks to your help) but still don't get it.
Let me resume - I have this annotation layer with a point feature and a
text, which is the (sub)title of my map.
With it's default values it is perfectly visible, including font and color
specifications. Trouble starts when I try to change the text via code...
LAYER
NAME "subtitESP"
STATUS ON
TRANSFORM FALSE
TYPE ANNOTATION
FEATURE
POINTS 435 10 END
TEXT "Merops apiaster" # this is the text to be changed!!!!
END
CLASS
LABEL
TYPE TRUETYPE #BITMAP
FONT verdana-italic
SIZE 12
POSITION LL
COLOR 160 90 0
END
# TEXT "Steve's method"
END
END
..Steve suggested to use the class text property instead of the feature so I
commented out the feature part, but no luck.....
<?php
$map_path="c:/web/";
$map_file="test.map";
$map=ms_newMapObj($map_path.$map_file);
$img=$map->draw();
$imgURL=$img->saveWebImage();
$subtitESP=$map->getLayerByName('subtitESP');
# Steve's suggestion: edit the TEXT property of the class:
$clObj=$subtitESP->getClass(0);
//$clObj->setText('Steve');
.....here I get 'Wrong parameter count for settext()'
# ..Sean and Eric suggested more or less the same: to remove the feature and
add a new feature: This is the part where I get a bit lost - do I have to
specify the line object? set the point coordinates to map or to image
coordinates? I get no error message but the new text doesn't show either.
$myshpObj=ms_NewShapeObj(MS_SHAPE_LINE);
$p=ms_newPointObj();
$l=ms_newLineObj(); # according to the MapScript Class Ref - this is the
onlytype that can be added to a shape???
//$p->setXY(1185001, 4879000); # (635,10) map or img coords????
$p->setXY(635, 10);
$l->add($p);
$myshpObj->add($l);
$myshpObj->set('text', 'Sean and Eric');
//$subtitESP->addFeature($myshpObj, MS_SHAPE_LINE);
$subtitESP->addFeature($myshpObj);
$subtitESP->draw($img);
$imgURL=$img->saveWebImage();
?>
<html>
<body>
<form name="mapa" method="get" action=<?php echo
$HTTP_SERVER_VARS['PHP_SELF']?>>
<input type="image" name="image" src="<?php echo $imgURL ?>" ></br>
</form>
</body>
</html>
More information about the MapServer-users
mailing list