[OpenLayers-Users] OpenLayers, Geoserver and Projections.

Mapmaker bmcbride at chacompanies.com
Fri Mar 26 09:11:36 EDT 2010


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}
    );
-- 
View this message in context: http://n2.nabble.com/OpenLayers-Geoserver-and-Projections-tp4802763p4803747.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list