Dynamic point layer via mapscript

Ethan Alpert ealpert at DIGITALGLOBE.COM
Wed Dec 29 16:30:34 EST 2004


I usually call $layer->close() before I draw.

-e

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu] On
Behalf Of Camden Daily
Sent: Wednesday, December 29, 2004 2:27 PM
To: MAPSERVER-USERS at lists.umn.edu
Subject: [UMN_MAPSERVER-USERS] Dynamic point layer via mapscript


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