[OpenLayers-Dev] initResolutions issue
Sébastien Roch
roch.sebastien at gmail.com
Thu Nov 29 10:22:31 EST 2007
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
}
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 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!
The real problem is that my scales array for the layer doesn't begin
with the same scale values as the one of the map.
I want that :
map : [1924725, 300000, 150000 ,60000 ,30000 ,15000 ,7500
,6000 ,4000 ,2000 ]
| | | |
| | | | | |
layer: (not visible) (not visible) [150000, 60000,30000, 15000,
7500,6000, 4000, 2000 ]
but we get :
map : [1924725, 300000, 150000 ,60000 ,30000 ,15000 ,7500 ,6000 ,4000 ,2000 ]
| | | | |
| | | | |
layer: [150000, 60000, 30000, 15000, 7500, 6000, 4000,
2000] (*) (*)
(*) = resolution undefined here
If this structure is kept, we have to find a manner to shift this
array or something like that.
Personnaly I think it would be good to reconsider the manner of
defining zoom levels for the user :
minScale/maxScale/maxResolution/... have to be respected
I noticed also that numZoomLevels for the map is not properly set (16
by default), while I gave it a scales array in option.
I'm using OL 2.5.
Cheers,
Sebastien
More information about the Dev
mailing list