[OpenLayers-Users] OpenLayers, Geoserver and Projections.

Mike Adair madair at dmsolutions.ca
Fri Mar 26 09:28:44 EDT 2010


Note also that the UTM transformations are not built into OpenLayers so 
you will also need to:
- include the Proj4js library in a script tag
- include the projection definition for EPSG:25832

Proj4js.defs["EPSG:25832"] = "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs";


Mike


Mapmaker wrote:
> Hi Casper,
>
> Your base layers should all be in the same projection.  So if you want to
> use Google, Bing, OSM, etc. you should set your map projection to web
> mercator (EPSG:900913).  If you want your map information (coordinate
> readout, etc.) displayed in EPSG:25832, you should set your
> displayProjection to EPSG:25832.
>
> If you are using GeoServer, your overlay layers will reproject "on the fly"
> without any trouble.  See below for an example...
>
> var options = {
>    projection: new OpenLayers.Projection("EPSG:900913"),
>    displayProjection: new OpenLayers.Projection("EPSG:4326"),
>    units: "m",
>    maxResolution: "auto",
>    maxExtent: new
> OpenLayers.Bounds(-75.86,44.05,-74.526,45.016).transform(new
> OpenLayers.Projection("EPSG:4326"), new
> OpenLayers.Projection("EPSG:900913"))
>             };
>
> map = new OpenLayers.Map('map', options);
>
> var gmap = new OpenLayers.Layer.Google(
>    " Google Streets",
>    {type: G_NORMAL_MAP, 'sphericalMercator': true, numZoomLevels: 22}
>     );
>
> var myoverlay = new OpenLayers.Layer.WMS("My Overlay Layer",
>    "http://www.myserver.com/geoserver/wms", 
>    {layers: 'mynamespace:mylayer', transparent: true, format: "image/png"},
>    {isBaseLayer: false, 'visibility': true, displayInLayerSwitcher: true}
>     );
>   

-- 
   Michael Adair
   Senior Software Architect
   DM Solutions Group Inc.

   Office: (613) 565-5056 x26
   madair at dmsolutions.ca
   http://www.dmsolutions.ca
   http://research.dmsolutions.ca





More information about the Users mailing list