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
|
* @param {Boolean} noEvent
|
||||||
*/
|
*/
|
||||||
setBaseLayer: function(newBaseLayer, noEvent) {
|
setBaseLayer: function(newBaseLayer, noEvent) {
|
||||||
|
var oldBaseLayer = this.baseLayer;
|
||||||
|
|
||||||
if (newBaseLayer != this.baseLayer) {
|
if (newBaseLayer != oldBaseLayer) {
|
||||||
|
|
||||||
// is newBaseLayer an already loaded layer?
|
// is newBaseLayer an already loaded layer?
|
||||||
if (this.layers.indexOf(newBaseLayer) != -1) {
|
if (this.layers.indexOf(newBaseLayer) != -1) {
|
||||||
|
|
||||||
// make the old base layer invisible
|
// make the old base layer invisible
|
||||||
if (this.baseLayer != null) {
|
if (oldBaseLayer != null) {
|
||||||
this.baseLayer.setVisibility(false, noEvent);
|
oldBaseLayer.setVisibility(false, noEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set new baselayer and make it visible
|
// set new baselayer and make it visible
|
||||||
@@ -368,13 +369,9 @@ OpenLayers.Map.prototype = {
|
|||||||
//redraw all layers
|
//redraw all layers
|
||||||
var center = this.getCenter();
|
var center = this.getCenter();
|
||||||
if (center != null) {
|
if (center != null) {
|
||||||
var zoom = this.getZoom();
|
var oldResolution = oldBaseLayer.getResolution();
|
||||||
this.zoom = null;
|
var zoom = this.baseLayer.getZoomForResolution(oldResolution);
|
||||||
if (zoom > this.baseLayer.numZoomLevels - 1) {
|
|
||||||
zoom = this.baseLayer.numZoomLevels - 1;
|
|
||||||
}
|
|
||||||
this.setCenter(center, zoom);
|
this.setCenter(center, zoom);
|
||||||
|
|
||||||
}
|
}
|
||||||
if ((noEvent == null) || (noEvent == false)) {
|
if ((noEvent == null) || (noEvent == false)) {
|
||||||
this.events.triggerEvent("changebaselayer");
|
this.events.triggerEvent("changebaselayer");
|
||||||
|
|||||||
Reference in New Issue
Block a user