Using base layer of two different projections (Spherical Mercator and WGS84) in OpenLayers

I've been looking into this recently, and this is one of the top search results, I figured i'd add some breadcrumbs to my research and experimentation.

Long and Short:

The 2.X line of Open Layers does not support this. The Map, it's properties such as center, resolution and extents are set by the INITIAL base layer of the map. Change to another base layer DOES NOT adjust these properties, so the outcome is unknown. Often, you get a center point/bounds that are not valid for the base layer you are changing to, so you see white tiles. But that is not ALWAYS the outcome (for example, switching from 4326 to 900913 will bring you to a point close to 0degN,0degE).

But, hope is not lost.

Near term:

Some patches were written against open layers that attempt to patch this for the map and many of the layers (see [1]). This comes from a bug filed over 6 (6!!!) years ago [2]. While you'd have to host your own version of OL and patch it by hand (the patch will not apply cleanly to the latest versions, so you have to manually do the edit), this will get you mostly where you want to be. Very nasty, and doesn't handle everything, but overall, gets someone who NEEDS multiple baselayers with different projections on their feet.

Long term:

This is exactly one of the things that OpenLayers 3.0 is hoping to address[3].

One example is the base layer/overlay dichotomy. It is often a challenge to know how and where to set resolutions, maxExtent, etc. for the map. Projection handling between map and layers and the interplay between projection and properties like maxExtent and center are complicated at best.

The Map object in 2.X relied too heavily on the base layer, and that is going to change going forward. So, if you can hold out until late 2013, there may be a pre-made solution for you to use.

[1] http://trac.osgeo.org/openlayers/attachment/ticket/1249/NEW.Reproject.patch
[2] http://trac.osgeo.org/openlayers/ticket/1249
[3] http://openlayers.org/blog/2012/11/14/why-are-we-building-openlayers-3/