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

Vinko Vrsalovic vinko at cprsig.cl
Fri Sep 26 14:26:50 EDT 2003


On Fri, Sep 26, 2003 at 12:40:25PM +0200, Frieso ter Haseborg wrote:
> 
> So obviously the changes are stored in the map, but they don't take any
> effect.
 
One layer is a collection of figures of some type, a class defines
how a certain figure will be drawn based on a certain attribute
(CLASSITEM) or characteristic, so, to draw differently two or more 
features on one layer, you must add as many classes as different 
colors (or symbols, etc) you need.
 
> IMHO this can't take any effect since I got a new class, but the next
> point doesn't know it has to use this new class.
 
Exactly, that's why you need to set the class index in the
$point->draw() call:

int draw(mapObj map, layerObj layer, imageObj img, 
            int class_index, string text)

The fourth parameter is what you need to change:

> >> $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 = ms_newClassObj($layer);    //new class instance
> >> $style = ms_newStyleObj($class);	    //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, 1, "Pt2");
				     ! <- here

Another way to do this is through addFeature(), this is the way i do it
because i usually need to add polygons and lines besides points, i'll
send an example if needed.

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



More information about the mapserver-users mailing list