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

David Fuhry dfuhry at gmail.com
Sun Apr 21 13:17:17 PDT 2013


I resolved the previous problem but ran into another: when an XYZ layer has
"isBaseMap: false", has maxExtent set, and has a non-default tileOrigin,
the getXYZ method in Layers/XYZ.js incorrectly calculates the x, y, and z
coordinates based on the layer's maxExtent bounds rather than on its
tileOrigin property. I fixed this problem by replacing
"this.maxExtent.left" with "this.tileOrigin.lon" and replacing
"this.maxExtent.top" with "-this.tileOrigin.lat" in the getXYZ method of
Layers/XYZ.js.

I hope this helps somebody and that OpenLayers can be patched to fix the
bug. I am using 2.12.

-Dave


On Sun, Apr 21, 2013 at 11:46 AM, David Fuhry <dfuhry at gmail.com> wrote:

> Hi Rohan or others,
>
>    Wondering if you ever found a resolution for this problem. What I'm
> experiencing is when using an XYZ layer with isBaseMap: false, setting
> maxScale to anything other than NaN or null, or setting minResolution to
> anything other than null, or 'auto', results in the layer never displaying.
> Obviously I want to set maxScale or minResolution to a numeric value, but
> the layer simply never displays when I do, no matter what the numeric value.
>
> Thanks,
>
> Dave
>
>
> 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/20130421/7545fec7/attachment.html>


More information about the Users mailing list