(Apologies if this comes through twice, I don't think my first attempt worked.)
Hi,
In my application I would like to be able to switch smoothly between
projections, particularly between lat-lon (EPSG:4326) and north polar
stereographic (NPS, EPSG:32661).
I have noticed that the switch from lat-lon to NPS is very slow and have been
trying to find out why. Debugging in Firebug reveals that OpenLayers tries to
load 35-40 tiles during the switching process. Only the last 4 tiles are the
ones that are needed to display the map in NPS, but the previous 35-ish are
spurious.
Looking at the request strings, it seems that these spurious tiles have an
extent that is more consistent with lat-lon than with NPS. My code looks like
this:
function changeProjection()
{
var proj = ... // new projection code
var newBaseLayer = getBaseLayerForProj(proj);
// Set the parameters of the map
map.setOptions({
projection: proj,
maxExtent: newBaseLayer.maxExtent,
resolutions: newBaseLayer.resolutions,
maxResolution: newBaseLayer.maxResolution
});
map.zoomToMaxExtent();
map.setBaseLayer(newBaseLayer);
}
getBaseLayerForProj() finds a Layer object that is requestable in the new
projection. (Not all WMS servers can return imagery in NPS projection.)
There is another clue: zoomToMaxExtent() doesn't work as I expected. Instead
of zooming the map to an extent suitable for a NPS map (in this case,
(-4350000,-4350000 -> 8350000, 8350000)), it zooms to a much smaller extent
(-180,-140 -> 180,140). The map only zooms to the full NPS extent after
setBaseLayer().
It is the setBaseLayer() method that seems to trigger all the spurious
tile-loading, and this is the slowest method in the above scheme.
So my guess is that the setting of the maxExtent of the map to the extent of
NPS is being restricted by the extent of the currently-displayed base layer,
meaning that the map does not zoom out to the correct extent. So when
setBaseLayer() is called, OL tries to load tiles using SRS=32661, but with
BBOXes that are more appropriate to a lat-lon map. Only after a large number
of tiles have been loaded does OL "realise" that the extent of the map has
changed, and finally loads the four tiles with the BBOXes I really wanted.
If I'm right, then I guess I need to find a way of changing the map's
projection in an "atomic" way that doesn't trigger lots of tiles to be loaded
during the process of changing the projection.
(By the way, I tried removing and hiding the current baselayer, changed the
projection and then added a new baselayer afterwards. But the setBaseLayer()
method exhibits the same behaviour.)
Thanks in advance for any help, and sorry for the long email!
Jon
--
Dr Jon Blower
Technical Director, Reading e-Science Centre
Environmental Systems Science Centre
University of Reading, UK
Tel: +44 (0)118 378 5213
http://www.resc.reading.ac.uk
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users