[OpenLayers-Users] Setting layer maxResolution and numZoomLevels

rickm81 rickm81 at yahoo.com
Fri Apr 12 06:50:57 PDT 2013


After quite a bit of digging online I was able to find a solution to this
common issue in Open Layers and its supported map layers. 

The issue I had was specifically tied to OpenStreetMaps. I found that it was
necessary that I explicitly define all resolutions with the necessary
zoomOffset in the OSM layer constructor. 

Using the the constructor below I was able to create the layer as I liked.

                var osm_wms = new OpenLayers.Layer.OSM("OSM", null, {
isBaseLayer: true, wrapDateLine: true, displayInLayerSwitcher: true,
zoomOffset: 4, resolutions: [9783.939618750003, 4891.969809375002,
2445.984904687501, 1222.99245234375, 611.4962261718752, 305.7481130859376,
152.8740565429688, 76.4370282714844, 38.2185141357422, 19.1092570678711,
9.55462853393555, 4.77731426696777, 2.38865713348389, 1.19432856674194] });

Resolutions can manually be added by starting with 1.19432856674194 and
adding multiples of two.

I then set the desired map zoom and center without issue. Just thought I
would add a quick update, since layer extent/zoom level seems to be a common
source of confusion for those new to OpenLayers.



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Setting-layer-maxResolution-and-numZoomLevels-tp5044883p5046405.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list