Dynamic point layer via mapscript

Eric Bridger eric at GOMOOS.ORG
Thu Dec 30 09:19:18 EST 2004


On Wed, 2004-12-29 at 16:26, Camden Daily wrote:
> 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);
>

I think when you call $image = $map->draw();  you are probably
overwriting the previous $image = $map->prepareImage(). Try skipping
that.
You should also try skipping $layer->draw(). You've already drawn this
layer using $point->draw(), no need to call layer->draw().

HTH.
Eric



More information about the mapserver-users mailing list