It might be common sense, but I missed it so this detail will save many folks a fair bit of confusion
This should be identified in the DOCs
to use zoombox you must enable navigation.

Comments

spydmobile’s picture

Another DOC ommision
to use a WMS layer as an overlay layer by setting

'baselayer' => false,

You must also set the params as follows:

'params' => array(
       'transparent' => TRUE,
        ),

If you dont, the WMS will be rendered opaque and this will force the layer to be presented as a BASE layer

tmcw’s picture

The former, yes, that's going in the documentation, the second is an upstream fix for the OpenLayers javascript library, not something for the openlayers module.

phayes’s picture

Status: Active » Fixed

Fixed: http://drupal.org/cvs?commit=281022

Although technically the transparency issue should be fixed in openlayers.js, it is pretty confusing, so I added a small check and fix.

For the ZoomBox I considered doing the same sort of check and fix, but I think this is better taken care of in documentation, since controls are almost always set explicitly. I've updated the docs.

tmcw’s picture

Eh, sorry, I misread the deal with the WMS layer information.

I think that the problem isn't... really a problem? Like, the problem is that you aren't setting the layer to be transparent besides filled areas. The opaque layer is still an overlay (like, you could want it to be as it is so that you could set it to 25% opacity or whatever as an overlay), not a base layer in OpenLayers's book. The fix should be a fix in the layer definition, and eventually a WMS client which lets all params be set, not an invisible automatic parameter, which will only cause confusion and possibly bugs if people use WMS servers which fail on the transparent parameter.

spydmobile’s picture

Sorry tmcw, I am unsure what you mean.
I was trying to explain that:
If you set the param to make your layer a baselayer, The assumption of the user will be that if I set this, it will be rendered as baselayer and appear as a radio in the base layer group and if they set it false that it will be an overlay as a checkbox in overlays,

but if you dont set the transparency, the base layer param is overridden and the user wont know why unless this is explained in the Dox.

This will probably only affect WMS layers.
Does that make more sense than what I said earlier?
F

tmcw’s picture

Okay, so this is a problem in the ridiculous API of OpenLayers. In the WMS layer type,

    /** 
     * APIProperty: noMagic 
     * {Boolean} If true, the image format will not be automagicaly switched 
     *     from image/jpeg to image/png or image/gif when using 
     *     TRANSPARENT=TRUE. Also isBaseLayer will not changed by the  
     *     constructor. Default false. 
     */ 
    noMagic: false,

and

        //layer is transparent        
        if (!this.noMagic && this.params.TRANSPARENT && 
            this.params.TRANSPARENT.toString().toLowerCase() == "true") {
            
            // unless explicitly set in options, make layer an overlay
            if ( (options == null) || (!options.isBaseLayer) ) {
                this.isBaseLayer = false;
            } 
            
            // jpegs can never be transparent, so intelligently switch the 
            //  format, depending on teh browser's capabilities
            if (this.params.FORMAT == "image/jpeg") {
                this.params.FORMAT = OpenLayers.Util.alphaHack() ? "image/gif"
                                                                 : "image/png";
            }
        }

I think that the solution is to set noMagic to true to stop OpenLayers from shooting us in the feet all the time.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.