[OpenLayers-Dev] initResolutions issue (reformated...)

Eric Lemoine eric.c2c at gmail.com
Thu Nov 29 14:45:14 EST 2007

On Nov 29, 2007 4:50 PM, Sébastien Roch <roch.sebastien at gmail.com> wrote:
> Hi dev,
> I'm working on a project with a lot of layers, which only appear at
> some levels regarding each layer.
> I got some problems with my map and layer configurations, and after
> code reviewing, want to expose you the problem :
> this is my map options:
> {       controls : []
>         units : "m",
>         projection : "EPSG:21781",
>         maxExtent: new OpenLayers.Bounds(484250,63254,837789,299902),
>         scales: [1924725,300000,150000,60000,30000,15000,7500,6000,4000,2000],
>         numZoomLevels : 10,
>         theme : null // disable default theme (or default css is imported)
> };
> and the options of a ka-map layer :
> {       format : "image/png",
>         buffer: 1,
>         scales : [150000,60000,30000,15000,7500,6000,4000,2000],
>         isBaseLayer: false,
>         visibility: false
> }

One unrelated comment: shouldn't format be a param as opposed to an
option? (I'm not sure about ka-map, for for a wms layer, format is a
param not an option)

Also, you use isBaseLayer:false. Do you really want that?

> So what I want is having this ka-map layer displayed only at these
> given scales. After having checked the code, I understood I can't just
> use the minScale and maxScale options : as the option scales is set
> for the map, the layer will inherit of it, and we jump then in a
> if-bloc which doesn't care of minScale/maxScales... (see
> Layer.js/initResolutions)

I just looked at initResolutions() and actually the layer's options
(resolutions, scales, maxScale, minScale, etc.) have precedence over
the map's options. So, you should be able to set minScale and maxScale
at the layer level.

> I first thought I could repair that, but the problem is more tricky as
> it appears :
> the config above seems to work, but... if you zoomin to last zoom
> level and type "myLayer.getResolution()", it returns "undefined"...
> This because "map.getZoom" is taken as index to get the resolution of
> the layer  -  but there is no resolution for this index in its
> resolutions array!

What control do you use for zooming?

If you use the zoombar you should notice a change in its number of
zoom levels when you switch your base layer. Do you?

Could you tell more about your setup? In part. do you have both
baselayers and overlays?

More information about the Dev mailing list