[OpenLayers-Users] Is it possible to completely change the projection of a Map?

Nick Whitelegg nick at hogweed.org
Mon May 7 07:01:47 EDT 2007

Hello everyone,

As part of an OpenStreetMap editing application I'm doing, I would like to be 
able to replace not only the layers but also the projection of the base map. 
The application is a point-of-interest editor for OpenStreetMap, it allows 
users to use the OpenLayers Vector layer to trace the outlines of lakes and 
woods and also add POIs like hill summits. I want users to be able to switch 
between two base layers.

The two base layers comprise Freemap (OpenStreetMap rendering client) which is 
projected in Mercator, and the New Popular Edition (old Ordnance Survey maps 
of the UK) which has the OSGB36 projection.

At the moment I use a combination of PHP (i.e. completely reload the page from 
the server) and openlayers JS code to deal with the switch. In other words, 
the Map object created depends on a query string value. Can I instead do it 
all within OpenLayers without necessitating a page reload?

My current code is as below (the variable "basemap" ultimately derives from a 
query string value, and "converter" is a class I've written to deal with 
conversion between projections).


            if (basemap=="npe")
                cvtr = new converter("OSGB");

                /* NPE BEGIN  */
                map = new OpenLayers.Map('map',
                { maxExtent: new OpenLayers.Bounds (0,0,599999,999999),
                maxResolution : 8,
                units: 'meters' }

                base = new OpenLayers.Layer.WMS( "New Popular Edition",
                {'layers': 'npe'},{buffer:1} );
                // main freemap maps
                cvtr = new converter("Mercator");

                map = new OpenLayers.Map('map',
                { maxExtent: new OpenLayers.Bounds
                resolutions: [10],
                tileSize: new OpenLayers.Size(500,500),
                      units: 'meters' }

                base = new OpenLayers.Layer.WMS( "Freemap/Mapnik",
                            {buffer:1} );

More information about the Users mailing list