There are a few other issues which deal with aspects of this, but as far as I can gather, not specifically for WMS layers.

I have the following WMS layer:

$items = array();
$openlayers_layers = new stdClass;
$openlayers_layers->disabled = FALSE; /* Edit this to true to make a default openlayers_layers disabled initially */
$openlayers_layers->api_version = 1;
$openlayers_layers->name = 'icc_wms';
$openlayers_layers->title = 'ICC';
$openlayers_layers->description = 'ICC';
$openlayers_layers->data = array(
  'base_url' => 'http://shagrat.icc.es/lizardtech/iserv/ows?',
  'params' => array(
    'isBaseLayer' => 'true',
    'buffer' => '2',
    'ratio' => '1.5',
    'singleTile' => 0,
  ),
  'options' => array(
    'srs' => 'EPSG:4326',
    'TRANSPARENT' => 0,
    'exceptions' => 'application/vnd.ogc.se_xml',
    'format' => 'image/png',
    'layers' => 'mtc5m',
    'styles' => '',
  ),
  'layer_type' => 'openlayers_layer_type_wms',
);
$items["icc_wms"] = $openlayers_layers;
return $items;

Problem is the zoom levels don't allow me to get to the maximum zoom level, which I can see exists for this server via other implementations.

I have tried settings numZoomLevels as an option and even initializing a zoom level range array with no luck. The zoom bar always has the same number of elements and the maximum value is always 2 zoom levels short of the most detailed.

I would appreciate any pointers as to how to initially set the correct zoom levels for such a WMS layer, and I wonder can I achieve this adding/modifying values of the option array passed to OpenLayers.Layer.WMS() ?

Many thanks.

CommentFileSizeAuthor
#3 wms_numZoomLevels.patch2.59 KBMichaelP

Comments

tmcw’s picture

The best option is to set the resolutions attribute of the layer - numZoomLevels can't be counted on in any case, since the 'magic' code in OpenLayers for deriving resolutions is terribly unpredictable.

The existing maps that show deeper zoom levels - are these OpenLayers maps? Can you get their resolutions arrays by introspecting the javascript on the page?

tmcw’s picture

Status: Active » Postponed (maintainer needs more info)

We'll need more info to debug this.

MichaelP’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.59 KB

Sorry got a bit sidetracked there.

I couldn't see how to get the resolutions array, and finally set the numZoomLevels to 20 on the base layer (or first layer to be added to the map), and made the call to set the default resolutions array (openlayers_get_resolutions) conditional to their being a value for numZoomLevels defined, and this seems to work for my wms layer (giving me 20 resolutions and getting to the deepest).

However, worth noting @tmcw 's comment #1 which a glance at openlayers.js only reinforces.

Attaching patch to define maxZoomLevels on wms and make the resolution array default initialisation conditional to this - but not so sure that this should go forward?

Many thanks.

batje’s picture

Issue tags: +wms

subscribe

zzolo’s picture

Status: Needs review » Needs work

Hi. Sorry for the epic delay in this. I just want to follow up to see if this works, as I don't have any WMS layers to test easily, and since its been so long, just want to make sure its still relevant.

batje’s picture

Component: Layers » OL API
Assigned: Unassigned » batje

This is still relevant, and as mentioned, quite complex, as you can read in the openlayers documentation.

Am planning to work on this, since we need a maxzoomlevel on our wms map here http://www.devtrac.ug/ (it's in one of the coming sprints)

ken-g’s picture

Status: Needs work » Closed (outdated)