[Mapserver-users] can I use different symbols in thesamedynamiclayer?

Vinko Vrsalovic vinko at cprsig.cl
Thu Sep 25 20:05:42 EDT 2003


On Thu, Sep 25, 2003 at 05:00:25PM +0200, Frieso ter Haseborg wrote:
> Hi Eric,
> 
> nope, no success so far. I tried this:
> [...]
> $pt = ms_newPointObj();
> 
> $class = $layer->getClass(0);
> $style = $class->getStyle(0);
> $style->color->setRGB(0, 0, 255); //draw a blue point
> $style->set ( 'symbol', $sym1 );
> $pt->setXY( 2100000, 10100000 );
> $pt->draw($map, $layer, $image, 0, "Pt1");
> 
> $class = $layer->getClass (0);    //new class instance
> $style = $class->getStyle(0);	    //new style instance
> $style->color->setRGB(0, 255, 0); //draw a green one - !this failes,
> second symbol becomes blue also!
> $style->set ( 'symbol', $sym2 );
> $pt->setXY( 4400000, 10000000 );
> $pt->draw($map, $layer, $image, 0, "Pt2");
> [...]
>

Have you checked the output of $map->save()?

I think your problem is here:

> $class = $layer->getClass (0);    //new class instance
> $style = $class->getStyle(0);	    //new style instance

These are not _new_ instances, just the same instances as in the first
paragraph of your code, to draw different colors in the same class, you
must add new styles, so try this (untested):

$class = $layer->getClass(0);
$style = ms_newStyleObj($class);
$style->color->setRGB(...

If this doesn't work you could try creating different classes for
each point:

$class = ms_newClassObj($layer); 
//Here copy the properties of the original class to the new ones as in:
$originalclass = $layer->getClass(0);
$class->set('name',$originalclass->name); //and so on
$style = ms_newStyleObj($class);


-- 
Vinko Vrsalovic <el[|- at -|]vinko.cl>
http://www.cprsig.cl



More information about the mapserver-users mailing list