Skip to content

Commit

Permalink
Notes on incorrect maxResolution of 156543.0339 and defaults coupled …
Browse files Browse the repository at this point in the history
…with projection
  • Loading branch information
ahocevar committed Feb 29, 2012
1 parent cb71ecc commit b7eba35
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions notes/2.12.md
Expand Up @@ -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.
Expand Down

0 comments on commit b7eba35

Please sign in to comment.