[OpenLayers-Users] [OpenLayers-Dev] Display a subset of zoom levels

Frédéric Junod frederic.junod at camptocamp.com
Fri Mar 13 05:04:40 EDT 2009


Le Thu, 12 Mar 2009 16:48:52 +0100,
Andrea Battisti <battisti at actgate.com> a écrit :

> 
> > This is what you need: http://trac.openlayers.org/wiki/SettingZoomLevels
> >
> > fredj
> >
> >   
> 
> Frédéric,
> 
> I already knew about that page but I don't see there the answer to my
> question.
> 
> 
> Consider the following use case:
> 
> TMS Layer with 3 zoomlevels: 0, 1, 2
> The map has: maxResolution = 1000 and numZoomLevels = 3
> 
> I want to display only zoom levels 1 and 2.
> If I set:
> maxResolution = 500 and numZoomLevels = 2
> then the resolutions array will be: [ 500, 250 ] so 500 gets mapped to
> zl '0' and 250 to zl '1' of the tms layer.
> 
> My goal is to map that 500 to zl '1' and that 250 to zl '2' of the tms
> layer. Is this possible?

Ok, then you should use the new 'serverResolutions' property:

var map = new OpenLayers.Map('map', {
    maxResolution: 500,
    numZoomLevels: 2
});

var layer = new OpenLayers.Layer.TMS('layer name', '/the/url/', {
    serverResolutions: [1000, 500, 250],
    ...
});

(Not tested)

see: http://trac.openlayers.org/ticket/1944

fredj

> 
> 
> 
> > PS: you should use the users at openlayers.org mailing list for this kind of
> > question
> >   
> 
> I will in the future, thanks.
> 
> 
> > Le Thu, 12 Mar 2009 15:20:03 +0100,
> > Andrea Battisti <battisti at actgate.com> a écrit :
> >
> >   
> >> Hi All,
> >>
> >>
> >> is there a way to force openlayers to show only a subset of zoom levels
> >> for a given layer?
> >>
> >> As an example, if the map is configured using a (maxResolution,
> >> numZoomLevels) pair, the maxResolution is mapped to zoom level 0,
> >> maxResolution/2 to zl 1 and so on...
> >>
> >> Will it be possible to tell the map to display for example only the zoom
> >> levels > N, or say, only selected zoom levels, e.g. 2, 5, 7 ?
> >>
> >>
> >> Thanks in advance,
> >>
> >>     
> >
> >
> >   
> 
> 


-- 
Frédéric Junod
Camptocamp SA



More information about the Users mailing list