fix for #182 and #262 -- pick the best new resolution when changing baselayers, instead of just using the same index into the resolutions array.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1581 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -350,15 +350,16 @@ OpenLayers.Map.prototype = {
|
||||
* @param {Boolean} noEvent
|
||||
*/
|
||||
setBaseLayer: function(newBaseLayer, noEvent) {
|
||||
var oldBaseLayer = this.baseLayer;
|
||||
|
||||
if (newBaseLayer != this.baseLayer) {
|
||||
if (newBaseLayer != oldBaseLayer) {
|
||||
|
||||
// is newBaseLayer an already loaded layer?
|
||||
if (this.layers.indexOf(newBaseLayer) != -1) {
|
||||
|
||||
// make the old base layer invisible
|
||||
if (this.baseLayer != null) {
|
||||
this.baseLayer.setVisibility(false, noEvent);
|
||||
if (oldBaseLayer != null) {
|
||||
oldBaseLayer.setVisibility(false, noEvent);
|
||||
}
|
||||
|
||||
// set new baselayer and make it visible
|
||||
@@ -368,13 +369,9 @@ OpenLayers.Map.prototype = {
|
||||
//redraw all layers
|
||||
var center = this.getCenter();
|
||||
if (center != null) {
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
if (zoom > this.baseLayer.numZoomLevels - 1) {
|
||||
zoom = this.baseLayer.numZoomLevels - 1;
|
||||
}
|
||||
var oldResolution = oldBaseLayer.getResolution();
|
||||
var zoom = this.baseLayer.getZoomForResolution(oldResolution);
|
||||
this.setCenter(center, zoom);
|
||||
|
||||
}
|
||||
if ((noEvent == null) || (noEvent == false)) {
|
||||
this.events.triggerEvent("changebaselayer");
|
||||
|
||||
Reference in New Issue
Block a user