transparency not working in dynamic layer

Steve Lime steve.lime at DNR.STATE.MN.US
Tue Jul 5 18:08:26 EDT 2005


Unfortunately transparency is applied at the layer level, not at the feature level. What happens is that features are rendered into a temporary image that is ultimately blended with the main image. So, what you're trying cannot work. There is a bug filed to try and fix this but it will be awhile.

There is a workaround though. You need to compose your rectangle as a shape (use the toPolygon method) and then add the shape to the layer as a feature. Code might look like:

$rectobj->{maxy} =  35.516376;

# workaround for layer-level transparency
$shape =  $rectobj->toPolygon();
$layerobj->addFeature($shape);
$layer->draw($map, $img);

Not too bad...

Steve 

>>> Mark Phillips <mbp at GEOMTECH.COM> 07/04/05 7:28 PM >>>
Hi,

I'm using Perl mapscript to manually draw a rectangle on a map.  I'd
like the rectangle to be transparent, so I'm drawing it in a layer
that is already defined in the mapfile as follows:

    LAYER
      NAME         RECT
      STATUS       ON
      TYPE         POLYGON
      TRANSPARENCY 50
      CLASS
        COLOR         210 210 150
        OUTLINECOLOR  0   0 0
      END
    END

The rectangle always comes out opaque, though.  Here's the relevant part
of my perl script:

    $map = new mapscript::mapObj( ... );
    ...
    $img = $map->draw();
    ...
    $layerobj = $map->getLayerByName('RECT');
    $layerobj->{status} = 1;
    $rectobj = new mapscript::rectObj();
    $rectobj->{minx} = -82.331429;
    $rectobj->{maxx} = -82.323929;
    $rectobj->{miny} =  35.508876;
    $rectobj->{maxy} =  35.516376;
    $rectobj->draw($map, $layerobj, $img, undef, "");
    ...
    $img->save($filename);

Does anyone know what I'm doing wrong?  I've seen references to similar problems
with transparency in dynamic layers in the list archives, but I haven't seen
a resolution.

Thanks for any help,

--Mark

Mark Phillips @ Geometry Technologies LLC
77 Owenby Cove Road
Fairview, NC  28730
Phone: 828-628-0489
mbp at geomtech.com       http://www.geomtech.com



More information about the mapserver-users mailing list