| Version 10 (modified by crschmidt, 5 years ago) |
|---|
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.
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: "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 http://proj.maptools.org/faq.html#sphere_as_wgs84 for more information on why this is.
This can be added to /usr/share/epsg/proj 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
and in GeoServer 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]],
PROJECTION["Mercator_1SP_Google"],
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.
WMS/other Services Supporting EPSG:900913
| Service | Link | Layer |
| Nexrad WMS Weather Feed (updated every 5 minutes): | http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi | nexrad-n0r-900913 |
| CIA Factbook: | http://world.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/world/map/world-overlay.map | world |
