[OpenLayers-Users] maxresolution and minresolution does not work as expected

maven apache apachemaven0 at gmail.com
Mon Jun 17 00:25:25 PDT 2013


Hi:

I tried to add multiple layers to the map , each layer will server for a
special  level and extent.

For example:


               * var tresolution=[156543.03390625, 78271.516953125,
39135.7584765625,  19567.87923828125, 9783.939619140625,
4891.9698095703125,   2445.9849047851562, 1222.9924523925781];*
* var layers=[*
* {url:"http://a.tile.openstreetmap.org/${z}/${x}/${y}.png
",minzoom:0,maxZoom:4},*
* {url:"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png
",minzoom:5,maxzoom:7,maxExtent:[-180,-90,0,90]},*
* {url:"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png
",minzoom:5,maxzoom:7,maxExtent:[0,-90,180,90]}*
* ];*

Then I will create three OSM layers, and add them to the map.


* function createLayer(l){*
* var lay=new OpenLayers.Layer.OSM("xx",l.url,{*
* isBaseLayer : false,*
* alwaysInRange : false,*
* maxResolution : tresolution[l.minzoom],*
* minResolution : tresolution[l.maxzoom],*
* //maxExtent : l.maxExtent || [-180,-90,180,90],*
* crossOriginKeyword: null*
* });*
* return lay;*
* }*


* map=new OpenLayers.Map("map",{*
* resolutions:tresolution,*
* allOverlays:true,*
* layers:lays*
* });*
* map.setCenter(new OpenLayers.LonLat(659688.852138, 5710701.2962197),1);*
*
*
As is shown:

*server `a.tile` will server the data all over the world with level between
0 to 4.*
*
*
*server `b.tile` will server the data with extent of [-180,-90,0,90] with
level between 5 to 7 .*
*
*
*server `c.tile` will server the data with extent of [0,-90,180,90] with
level between 0 to 4.*

So in my opinion,when the zoom of the map is smaller than 5. OL will
request tiles from server `a.tile..`. Layer of  `b.tile` and `c.tile` will
be deactivated.

When the zoom is larger than 5, the layer with `a.tile` will be
deactivated. And if the view-port is inside *[-180,-90,0,90], *then
`b.tile` will be activated.

In a world, the layer should be activated(visible and request data) or
deactivated(invisible and not request data) according to the min/max
resolution and extent.

However, I found that it does not work as expected. Live
Demo<http://jsfiddle.net/EQghk/1/>.
And I meet some problems:

1) When the map is initialized, its zoom is set to be 1, but from the
firebug, I found that it will request images like `a.tile..../2/....png`,
It seems that the current zoom is 2 rather than 1.


2) When I zoom to level 6(through the firebug), I found that both layer
`a.tile..` `b.tile...`, `c.tile..` are activated. Why the layer `a.tile..`
is not deactivated? It seems that the min/max resolution does not work.

3) If I un-comment the line *maxExtent : l.maxExtent ||
[-180,-90,180,90], *then
the Firefox will crashed, and the chrome will throw error "Cross-origin
image load denied by Cross-Origin Resource Sharing policy. ".

What is the problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130617/fe13befa/attachment-0001.html>


More information about the Users mailing list