Can't handle to use a WMS layer as a base layer, cause after setting the layer (openlayers/layers/Base/edit) as a BaseLayer
it still only shows up in the "Overlay layers" list on preset edit (openlayers/presets/4326/edit - Layers&style tab)

Comments

batje’s picture

Hi,

I spent a few days learning openlayers and trying to find this. Here is my current workaround.

The current isBaselayer setting on a wms map, only can tell WMS that this is a baselayer, but not the drupal openlayers module. You have to add a second parameter for that in includes/layer_types/wms.inc
Besides that, the value returned for isBaselayer has to read 'true' not 1 or 0.

      'baselayer' => array(
          '#type' => 'checkbox',
          '#default_value' => isset($this->data['params']['isBaseLayer']) ?
            $this->data['params']['isBaseLayer'] : true,
          '#title' => t('BaseLayer'),
          '#return_value' => 'true',
          '#description' => t('Uncheck to make this map an overlay')
        ),

      // TODO: swap terms
      'params' => array(
        'isBaseLayer' => array(
          '#type' => 'checkbox',
          '#default_value' => isset($this->data['params']['isBaseLayer']) ?
            $this->data['params']['isBaseLayer'] : TRUE,
          '#title' => t('BaseLayer'),
          '#return_value' => 'true',
          '#description' => t('Uncheck to make this map an overlay')
        ),

This is definitely ugly, but it works.

Then, you might run into projection issues. (i did) in the openlayers.js file, here is what i found:

          if (map.projection === '900913') {
            options.maxExtent = new OpenLayers.Bounds(
              -20037508.34, -20037508.34, 20037508.34, 20037508.34);
            options.units = "m";
          }

Telling openlayers the units are in 'm' does not change the behaviour of OSM & Google, but it fixes scaling issues in WMS.

3 lines further

            options.maxResolution = "auto"; //1.40625;

Not sure why that value is hardcoded. Using auto fixes the rest of trouble i had with WMS.

As i said, i am learning while doing, so I might have broken other things out of noobing around.

The only issue I can see so far is that our geowebcache on *some* zoomlevels is shifting the background projection. The same tiles, served from geoserver directly are perfectly fine. I had not noticed before (how could i, i didnt have a wms baselayer), so might not be related.

Hope that helps you and the developers.

(6-8-2010 added some detail)

tmcw’s picture

Status: Active » Fixed

Fixed in: http://drupal.org/cvs?commit=403394

batje: can you open a ticket for the specific projection problems you're experiencing?

strk’s picture

Tested and confirm the fix. Thanks.

batje’s picture

There is an issue for the WMS resolution here

http://drupal.org/node/878644

and for the geowebcache issue here

http://drupal.org/node/878662

Status: Fixed » Closed (fixed)

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