[MapProxy] transparency with a WMS layer

Oliver Tonnhofer tonnhofer at omniscale.de
Fri Feb 24 12:13:21 EST 2012


On 24.02.2012, at 17:41, Paolo Corti wrote:
> Here is my problem: I have a WMS layer, from MapServer, defined in the
> yaml file in this way:
> sources:
>  hotspots_wms:
>    type: wms
>    req:
>      url: http://localhost/mapserver/global?
>      layers: hotspots
>      transparent: true
>      map: /path/to/my/mapfile.map
>      transparent: true
>      image:
>        transparent_color: '#ffffff'
>        transparent_color_tolerance: 20

The image options do not belong to req, you need to unindent it one step. But you don't need this option if your MapServer already returns transparent images (which it does).

> With OpenLayers this is how I have defined the layer:
> […]
>    var mapproxy_layer = new OpenLayers.Layer.WMS( "MapProxy Hotspots",
>            "http://localhost:8081/service?", {layers:
> "effis_hotspots", format: 'image/jpeg'},
>            mapproxy_params );

You need to tell OpenLayer that this layer it transparent:

>    var mapproxy_layer = new OpenLayers.Layer.WMS( "MapProxy Hotspots",
>            "http://localhost:8081/service?", {layers:
> "effis_hotspots", format: 'image/jpeg', transparent: "true"},
>            mapproxy_params );

> It seems that the transparency of the layers is lost, and white has
> became the background color.
> Any idea about what is going wrong with this?
> I have seen a couple of threads about opacity problems, but not sure
> they are related to my problem.

The WMS option `transparent` defaults to false and the background is then set to the value of the WMS `bgcolor` option, which is white.


Oliver Tonnhofer    | Omniscale GmbH & Co KG    | http://omniscale.de
http://mapproxy.org | https://bitbucket.org/olt | @oltonn

More information about the MapProxy mailing list