[OpenLayers-Dev] preserving scale on base layer switching

Tim Schaub tschaub at opengeo.org
Wed Feb 3 12:17:27 EST 2010

Andreas Hocevar wrote:
> Tim Schaub wrote:
>> Currently, when a new base layer is set, we determine the new 
>> resolution based on the previous map extent.  An alternative would be 
>> to determine the new resolution based on the previous scale.  
>> Preserving center and scale makes better sense to me.  I'm curious 
>> what others think.
> I totally agree. This should also improve behavior when switching 
> between base layers with different projections/units.

Thanks for the feedback.  I put this in with r10014.  (By the way, how 
did we forget to celebrate http://trac.openlayers.org/changeset/10000 ???)

If anybody notices any funkiness, please re-open ticket #2457 or create 
a new one.  I removed a couple conditions that seemed unnecessary to me 
- but perhaps there were real cases for them (e.g. prefer 
map.getExtent().getCenterLonLat() over map.getCenter()).

At least now you can center your dateline-wrapping map on the Bering Sea 
and switch base layers without ending up in Denmark.


> -Andreas.
>> The resolution based on extent method breaks down when extents are not 
>> well defined.  E.g. with an extent that wraps the date line.  To see 
>> this break-down in action, follow these steps:
>> 1) open http://openlayers.org/dev/examples/google.html
>> 2) click to zoom all the way out (you'll see multiple worlds)
>> 3) open the switcher and change base layers
>> You should see the scale change.
>> Apply the patch for http://trac.openlayers.org/ticket/2457 and you 
>> should see better behavior.
>> Thanks for any feedback.
>> Tim

Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.

More information about the Dev mailing list