In changing base layers, we now rely on the old map resolution instead of the old map zoom. This means that for layers with different resolutions arrays, we try to keep the map resolution as consistent as possible (instead of keeping an arbitrary zoom level consistent). This change also fixes a bug that comes up in changing base layers for layers with different length resolution arrays (closes #1032).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4682 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -109,6 +109,12 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
*/
|
||||
center: null,
|
||||
|
||||
/**
|
||||
* Property: resolution
|
||||
* {Float} The resolution of the map.
|
||||
*/
|
||||
resolution: null,
|
||||
|
||||
/**
|
||||
* Property: zoom
|
||||
* {Integer} The current zoom level of the map
|
||||
@@ -703,7 +709,11 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
if (center != null) {
|
||||
if (oldExtent == null) {
|
||||
// simply set center but force zoom change
|
||||
this.setCenter(center, this.getZoom(), false, true);
|
||||
this.setCenter(
|
||||
center,
|
||||
this.getZoomForResolution(this.resolution),
|
||||
false, true
|
||||
);
|
||||
} else {
|
||||
// zoom to oldExtent *and* force zoom change
|
||||
this.setCenter(oldExtent.getCenterLonLat(),
|
||||
@@ -1121,6 +1131,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
|
||||
if (zoomChanged) {
|
||||
this.zoom = zoom;
|
||||
this.resolution = this.baseLayer.getResolution();
|
||||
// zoom level has changed, increment viewRequestID.
|
||||
this.viewRequestID++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user