Notes on incorrect maxResolution of 156543.0339 and defaults coupled with projection

This commit is contained in:
ahocevar
2012-02-29 08:11:14 +01:00
parent cb71eccb34
commit b7eba35077

View File

@@ -84,8 +84,39 @@ The `OpenLayers.Tile.Image` class now has a method to get a canvas context for p
tileOptions: {crossOriginKeyword: null}
Both `OpenLayers.Layer.OSM` and `OpenLayers.Layer.Bing` do not have defaults for `maxExtent`, `maxResolutions` and `units` any more. This may break maps that are configured with a `maxResolution` of `156543.0339`, which was used in examples before 2.11, but is incorrect. The correct value is `156543.03390625`, but it is no longer necessary to specify a maxResolution, maxExtent and units if the correct resolution is set. See "Projection and Spherical Mercator" below.
## Projection & SphericalMercator
When working with Web Mercator layers (e.g. Google, Bing, OSM), it was previously necessary to configure the map or the base layer with the correct `projection`, `maxExtent`, `maxResolutions` and `units`. Now OpenLayers has defaults for WGS84 and Web Mercator in `OpenLayers.Projection.defaults`, so it is enough to provide the `projection`.
Old:
new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",
maxResolution: 156543.03390625,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
units: "m",
layers: [
new OpenLayers.Layer.Google("Google Streets"),
new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opcity: 0.7})
],
zoom: 1
});
New:
new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",
layers: [
new OpenLayers.Layer.Google("Google Streets"),
new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opcity: 0.7})
],
zoom: 1
});
In previous releases, coordinate transforms between EPSG:4326 and EPSG:900913 were defined in the SphericalMercator.js script. In 2.12, these default transforms are included in the Projection.js script. The Projection.js script is included as a dependency in builds with any layer types, so no special build configuration is necessary to get the web mercator transforms.
If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMercator` or `inverseMercator` methods, you may have to explicitly include the SphericalMercator.js script in your build. The Google layer is the only layer that depends on the SphericalMercator mixin. If you are not using the Google layer but want to use the SphericalMercator methods listed above, you have to explicitly include the SphericalMercator.js script in your build.