The world is not quite a sphere -- but the commercial mapping APIs tend to disbelieve that. They use a Mercator projection with an earth-as-a-sphere assumption. Please also read the detailed explanation

In order to interact with them, in OpenLayers 2.5 and beyond, you will create a layer with a sphericalMercator option set to true:

var layer = new OpenLayers.Layer.Google("Google", {"sphericalMercator": true});

This is the best way to overlay data on top of the Google Maps API in OpenLayers, and other alternatives may eventually not be supported. (This includes the 'reproject: true' option on WMS layers.)

The options you should use with this configuration are:

var options = {
    projection: new OpenLayers.Projection("EPSG:900913"),
    units: "m",
    maxResolution: 156543.0339,
    maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
                                     20037508.34, 20037508.34)

The projection in question can be expressed in proj4 as:

+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0
+k=1.0 +units=m +nadgrids=@null +no_defs

See for more information on why this is.

This can be added to /usr/share/epsg/proj, and thus MapServer, GDAL, etc. by adding the following line to the file:

<900913> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs

If, for whatever reason, you can't edit your system PROJ.4 definitions (i.e., don't have root), you can use the CONFIG "PROJ_LIB" option to the map object in MapServer, as described in the docs.

In GeoServer, you can define the Spherical Mercator projection as:

900913=PROJCS["WGS84 / Simple Mercator", GEOGCS["WGS 84",
DATUM["WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], 
PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], 
AXIS["Longitude", EAST], AXIS["Latitude", NORTH]],
PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], 
PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], 
PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST],
AXIS["y", NORTH], AUTHORITY["EPSG","900913"]]

Note that GeoServer versions 1.5.4 and above already include this definition, so no additional server side configuration is needed to overlay on OpenLayers as long as you are using the latest versions.

Note that GeoServer's WKT uses a special PROJECTION parameter which will probably not be supported by other software.

In PostGIS, you can run this sql script to add the correct projection setting:

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) values (900913 ,'EPSG',900913,'GEOGCS["WGS 84", DATUM["World Geodetic System 
1984", SPHEROID["WGS 84", 6378137.0, 298.257223563,AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], NIT["degree",0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH],AUTHORITY["EPSG","4326"]], PROJECTION["Mercator_1SP"],PARAMETER["semi_minor", 6378137.0], 
PARAMETER["latitude_of_origin",0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor",1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0],UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH],AUTHORITY["EPSG","900913"]] |','+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m 
+nadgrids=@null +no_defs');

WMS/other Services Supporting EPSG:900913

Nexrad WMS Weather Feed
(updated every 5 minutes):
CIA Factbook:

SphericalMercator and EPSG aliases

The SphericalMercator projection in OpenLayers uses code epsg:900913. When Google started to use the SphericalMercator projection, a corresponding EPSG code did not yet exist, so a temporary code '900913' (notice the resemblance to the word 'google') was invented. Many other services, such as OpenStreetMap, Bing and Yahoo are now also using the same projection, but are not necessarily supporting the use of code EPSG:900913. Other codes, such as EPSG:3857 and EPSG:102113 were invented. Today, there is an officially registered EPSG code 3857 whose projection is identical to EPSG:900913. ( So, if you need to combine overlay layers that are using either an alias or the official EPSG code with an OpenLayers SphericalMercator layer, you have to make sure that OpenLayers requests EPSG:3857 or other alias in stead of EPSG:900913. You can accomplish this by overriding the layer projection before adding the layer to the map. For example:

// create sphericalmercator layers
var googleLayer = new OpenLayers.Layer.Google("Google", {"sphericalMercator": true});
var osmLayer = new OpenLayers.Layer.OSM("OpenStreetMap");

// override default epsg code
aliasproj = new OpenLayers.Projection ("EPSG:3857");
googleLayer.projection = osmLayer.projection = aliasproj;

// set transformation functions from/to alias projection
OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.SphericalMercator.projectForward);
OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:4326", OpenLayers.Layer.SphericalMercator.projectInverse);

//add baselayers to map
map.addLayers([googleLayer, osmLayer]);

// now add overlay layers that support EPSG:3857 instead of EPSG:900913

Last modified 5 years ago Last modified on Jul 19, 2010 8:47:28 AM