[OpenLayers-Users] Changing map projections for WMS layers

Jon Blower jdb at mail.nerc-essc.ac.uk
Tue May 6 06:47:34 EDT 2008


Hi Eric (and list),

Thanks for this.  I now have a different problem, in that
map.zoomToMaxExtent() is not working as expected on my north polar
stereographic layer.  I have registered an event handler for
map.changebaselayer that looks like this:

function baseLayerChanged(event)
{
    // Change the parameters of the map based on the new base layer
    map.setOptions({
       projection: projCode,
       maxExtent: map.baseLayer.maxExtent
    });
    map.zoomToMaxExtent();
}

The base layers are set up with different projections (one in
EPSG:4326, the other in EPSG:32661).  Logging reveals that, when
switching to EPSG:32661, the maxExtent of the map is being set
correctly *but* the true extent of the map after the call to
zoomToMaxExtent() is not correct:

max extent of map: -10700000, -10700000, 14700000, 14700000
actual extent of map after call to zoomToMaxExtent: 1999640,
1999718.75, 2000360, 2000281.25

hence the map is only covering a very small portion of the true
maximum extent.  Are there other parameters that I should be setting
on the base map?  I am not setting resolution, minExtent or zoom
levels explicitly anywhere in my code.

The same thing happens if I call zoomToExtent() and pass in the
bounding box explicitly.

Thanks, Jon

On Sun, May 4, 2008 at 1:34 PM, Eric Lemoine <eric.c2c at gmail.com> wrote:
> On Fri, May 2, 2008 at 5:14 PM, Jon Blower <jdb at mail.nerc-essc.ac.uk> wrote:
>  > Hi all,
>  >
>  >  I am developing a WMS-based visualization site using OpenLayers and
>  >  I'd like to have the capability to change the projection of the map.
>  >  The map is created using EPSG:4326 but I'd like to be able to change
>  >  this dynamically to EPSG:32661 (north polar stereographic).  (so that
>  >  I can display layers from NSIDC, amongst others:
>  >  http://nsidc.org/data/atlas/ogc_services.html).
>  >
>  >  I've tried changing the projection like this:
>  >
>  >  map.setOptions({
>  >     projection: "EPSG:32661",
>  >     maxExtent: new OpenLayers.Bounds(-10700000, -10700000, 14700000, 14700000)
>  >  });
>  >
>  >  but nothing seems to happen.  The map doesn't change at all, even if I
>  >  zoom or pan.  Images are still requested using EPSG:4326 and the
>  >  extent remains unchanged.  (The base layer WMS can accept either
>  >  EPSG:4326 or EPSG:32661.)
>  >
>  >  All the layers on my map are WMS layers.
>  >
>  >  Do I need to change the projection of all the layers I'm viewing
>  >  individually?
>
>  yes, I think so.
>
>
>  > If so, what is the purpose of the projection of the map
>  >  object?
>
>  If a layer is created without a projection specified, its projection
>  is taken from what's specified in the map object.
>
>  --
>  Eric
>



-- 
--------------------------------------------------------------
Dr Jon Blower Tel: +44 118 378 5213 (direct line)
Technical Director Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre Fax: +44 118 378 6413
ESSC Email: jdb at mail.nerc-essc.ac.uk
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
--------------------------------------------------------------



More information about the Users mailing list