Dynamic point layer via mapscript

Camden Daily cdaily at GMAIL.COM
Wed Dec 29 16:26:47 EST 2004


Hello all.  I'm trying to do something which seems like it should be
simple, but for some reason it isn't working for me.

I have a .map file, and I'm trying to add a set of points to the map
using mapscript.  My code doesn't make mapserver crash or anything,
but the points don't show up on my rendered map.

The code I use to try to add a symbol for a specific point is:

$layer = ms_newLayerObj($map);
$layer->set("name", "points");
$layer->set("type", MS_LAYER_POINT);
$layer->set("status", MS_ON);

$class = ms_newClassObj($layer);
$class->set("status", MS_ON);

$class->label->set("font", "arial");
$class->label->color->setRGB(255, 0, 0);

$style = ms_newStyleObj($class);
$symbol = $map->getSymbolByName("square");
$style->set("symbol", $symbol);
$style->set("size", 8);
$style->color->setRGB(255, 0, 0);

$image = $map->prepareImage();

$point = ms_newPointObj();
$point->setXY($longitude, $latitude);
$point->draw($map, $layer, $image, 0, "test");
$layer->draw($image);

$image = $map->draw();
$image_url = $image->saveWebImage('MS_JPG', 1, 1, 0);

My map file is projected as latlong, and my $latitude and $longitude
values are in dd, the same as the map file extent.  If anyone has any
help on why my code might be failing, or could point me to a working
example, that'd be great.  I've scoured the archives and google, but
nothing I've seen seems to work for me.

-Camden



More information about the mapserver-users mailing list