[mapserver-users] Problem with transparency overlays

Alexandre Dube adube at mapgears.com
Fri Jan 30 05:31:02 PST 2009


Hi Rafael,

Here's what the doc has to say about the TRANSPARENT option in the MAP 
object :

<<<
TRANSPARENT [on|off]

    Use FORMATOPTION “TRANSPARENT=ON” in the /OUTPUTFORMAT/
    <http://mapserver.org/mapfile/outputformat.html#outputformat>
    declaration to specify if the output images should be transparent.

    Deprecated since version 4.6.

 >>>

So you should use OUTPUTFORMAT, for example like this :

<<<
OUTPUTFORMAT
NAME "agg"
MIMETYPE "image/png"
DRIVER AGG/PNG
EXTENSION "png"
IMAGEMODE RGBA
TRANSPARENT ON
FORMATOPTION "INTERLACE=OFF"
END
 >>>
(the above example uses the AGG driver)

Then, in your Openlayers layer's definition, use this param :
roads = new OpenLayers.Layer.MapServer( "Roads",
"http://192.168.1.100/cgi-bin/mapserv?map=us_states.map",
{layers: 'us_roads', map_imagetype: 'agg'}, {isBaseLayer:false});

The "transparent" option has no effects on a Layer.MapServer. It would 
have on a Layer.WMS though.

Be sure to look at the OUTPUTFORMAT documentation to pick the right 
image type you want to use.

Hope this helps,

Alexandre

Rafael chacón wrote:
> Hi, I'm having some trouble with transparency layers appear/disappear. 
> I'm working with MapServer and Openlayers... I want two layers to 
> overlay but when I choose to show one the other one hides... Here is 
> some of my code.... Thanks for the help :)
>
> Mapserver File:
>
> MAP
> size 800 600
> imagetype 'gif'
> TRANSPARENT ON
> imagecolor 0 0 255
> extent -180 -90 180 90
> SYMBOLSET "symbols"
> PROJECTION
> "init=epsg:4269"
> END
>
> WEB
> IMAGEPATH "/var/www/apache2-default/gis_tests/tmp/"
> IMAGEURL "/apache2-default/gis_tests/tmp/"
> TEMPLATE "empty.html"
>
> metadata
> wms_title "us_states"
> wms_srs "EPSG:4269"
> end
> end
>
>
> _______
>
> OPenlayers:
>
> layer = new OpenLayers.Layer.MapServer( "Estados unidos",
> "http://192.168.1.100/cgi-bin/mapserv?map=us_states.map",
> {layers: 'us_states', 'format':'image/png'});
> roads = new OpenLayers.Layer.MapServer( "Roads",
> "http://192.168.1.100/cgi-bin/mapserv?map=us_states.map",
> {layers: 'us_roads',transparent: 'true', 'format':'image/png'}, 
> {isBaseLayer:false});
> gps = new OpenLayers.Layer.MapServer( "GPS",
> "http://192.168.1.100/cgi-bin/mapserv?map=us_states.map",
> {layers: 'gps_points', transparent: 'true', 'format':'image/png' }, 
> {isBaseLayer:false});
>
> roads.setVisibility(false);
> gps.setVisibility(false);
>
>
> -- 
> Rafael Chacon,
>
> "El hombre es la medida de todas las cosas". Protagoras
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the MapServer-users mailing list