Hi,
You are right. PHP/MapScript doesn't provide the TEXT portion of an
annotation feature. It's because it's easier to add directly a point on
the top of the map. Instead of adding a FEATURE object to the layer,
simply create a point object and draw it on the map image.
(Following code not tested)
// Outside the loop create a pointObj
$oPoint = ms_newPointObj();
$oPoint->setXY(1,1);
[...snipp...]
// Inside the foreach, draw your map without the copyright layer
$thislayer->set("status",MS_OFF);
$image[$i] = $amap->map->draw();
// Then draw the point on the top of it
// Don't forget to remove the FEATURE object in the mapfile
// Also you should give a name to your class in the copyright layer
// For now, I'll use "CLASSNAME"
$thislayer->set("status",MS_ON);
$oPoint->draw($amap->map, $thislayer, $image[$i], "CLASSNAME",
$filter);
$image_url[$i] = $image[$i]->saveWebImage(MS_GIF,1,1,0);
[...snip...]
The code is not tested, but it should give you a good idea.
Julien
Burgholzer,Robert wrote:
I am trying to produce a time series animated GIF, with an annotation at
the bottom of the map that shows the time. Thanks to an example from
Charlton Purvis found by a search of previous postings on making an
animated GIF (modified to use a single layer, changing the filter to
select for the data that is in my current time step):
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0304/msg00482.html
And a Wiki entry from Jeff McKenna about making a copyright notation:
http://mapserver.gis.umn.edu/docs/faq/copyright-layer
I have the basics, that is, an animated time series, with a statically
placed text entry at the bottom (at a map-specific point, rather than a
lat lon). However, the annotation layer can only display a single
entry, not one that is updated with the time step. I am wondering how
to do this, if I can modify the property of the annotation layer, or if
I need to create a point of some sort from a dynamic postgis call. I
can’t seem to set the TEXT portion of the feature via php mapscript.
Anyone have any ideas? (code and mapfile follow)
foreach ($gifmaps as $thismap) {
$thislayer = $amap->map->getLayerByName('stream_stat');
$filter = " projectid = $projectid and thismetric = '$thismap' ";
$listobject->querystring = " select count(*) as numrecs from
proj_group_stat ";
$listobject->querystring .= " where $filter ";
$listobject->performQuery();
$numrecs = $listobject->getRecordValue(1,'numrecs');
#$annotlayer = $amap->map->getLayerByName('copyright');
#$annotation = $annotlayer->getFeature(1,-1);
if ($numrecs > 0) {
$thislayer->setFilter($filter);
$thislayer->set("status",MS_ON);
#$annotation->set("TEXT", $filter);
$image[$i] = $amap->map->draw();
$image_url[$i] = $image[$i]->saveWebImage(MS_GIF,1,1,0);
$file_path[$i] = $amap->map->web->imagepath
. substr(strrchr($image_url[$i], "/"),1);
$anim_files = $anim_files . '"' . $file_path[$i] . '"' . " ";
$i++;
print(" Adding <i>$filter</i>, $image_url[$i] <br>");
}
}
// Create a unique filename and URL for the animated GIF output
$anim_name = "anim".substr(strrchr($image_url[1], '/'),1);
$anim_path = '"' . $amap->map->web->imagepath . $anim_name .'"';
$anim_url = $amap->map->web->imageurl . $anim_name;
print("Creating $anim_path <br>");
$cmd = $anim_gif_cmd . " -o " . $anim_path . " " . $anim_files;
print("Using: $cmd <br>");
system($cmd);
# annotation layer
LAYER
NAME copyright
STATUS ON
TYPE annotation
TRANSFORM false
FEATURE
POINTS
150 180 #this is the position of the text in image coordinates
(pixels)
END
TEXT “From 2007/01/01 to 2007/06/30" #this is your displaying text
END
CLASS
LABEL #defines the font, colors etc. of the text
FONT "arial"
TYPE TRUETYPE
SIZE 10
BUFFER 1
COLOR 0 0 0
BACKGROUNDCOLOR 255 255 255
FORCE TRUE
END
END
END
Robert W. Burgholzer
Surface Water Modeler
Office of Water Supply and Planning
Virginia Department of Environmental Quality
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
804-698-4405
Open Source Modeling Tools:
http://sourceforge.net/projects/npsource/
--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/