[OpenLayers-Users] How to define levels of XYZ layer type by resolutions.

Rohan Parkes rohan.parkes at pelicancorp.com
Fri Jun 24 00:05:27 EDT 2011


I have a layer based on a 3rd-party map provider that uses an XYZ layer type
that is optimised to show Australia and New Zealand. If I just let the layer
run with sphericalMercator set to true, and don't set anything else,
everything's fine. However, I want to be able to limit the number of layers
available based on criteria like zoom level (e.g. the map should have zoom
levels between 20km and 1 km). I have been able to do this with other layer
types like ArcGIS93Rest by having a resolutions array in advance, and
truncating it according to the calculated zoom level and then passing it to
the map object.

 

I can't get the same idea to work if I use an XYZ layer. It won't work
properly if I pass in any array of resolutions, even if it's the same array
of Spherical Mercator resolutions that it generates itself. 

 

Based on the information in
http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels I've tried setting
the minZoomLevel/maxZoomLevel, minResolution/maxResolution. These seem to
have no effect, or they create bizarre results. The only setting that seems
to constrain the levels is numZoomLevels, but this doesn't give me any
control over which range of levels it selects - if I set it to 10, it
defaults to the outermost 10.

 

(I have the same issue with the OSM layer type, which I would like to have
as a fallback if the main map provider fails - again I can't seem to specify
the exact zoom levels I want.)

 

One issue - I'm not passing the array into the map constructor via the
options parameter during initialisation. Due to the way the code has been
written, it creates an empty map object, then sets various parameters. I
don't know it that's a factor.

 

One other thing that seems a bit odd - even if I can successfully set the
levels with a resolutions array, I still have to specify the number of zoom
levels in the map object. I thought it would figure this out itself from the
size of the array.

 

Rohan Parkes

Melbourne

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110624/efa6b940/attachment-0001.html


More information about the Users mailing list