Fixed zoomend event code; changed semantics of the argument to moveToNewExtent to make the argument be the *previous* zoom level. Added tests.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@66 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -241,10 +241,10 @@ OpenLayers.Map.prototype = {
|
||||
this.moveLayerContainer(latlon);
|
||||
}
|
||||
this.center = latlon.copyOf();
|
||||
var zoomChanged = false;
|
||||
if (zoom != null) {
|
||||
if (this.zoom && zoom != this.zoom)
|
||||
zoomChanged = true;
|
||||
var zoomChanged = null;
|
||||
if (zoom != null && zoom != this.zoom
|
||||
&& zoom >= 0 && zoom <= this.getZoomLevels()) {
|
||||
zoomChanged = (this.zoom == null ? 0 : this.zoom);
|
||||
this.zoom = zoom;
|
||||
}
|
||||
|
||||
@@ -254,17 +254,18 @@ OpenLayers.Map.prototype = {
|
||||
},
|
||||
|
||||
moveToNewExtent: function (zoomChanged) {
|
||||
if (zoomChanged) { // reset the layerContainerDiv's location
|
||||
if (zoomChanged != null) { // reset the layerContainerDiv's location
|
||||
this.layerContainerDiv.style.left = "0px";
|
||||
this.layerContainerDiv.style.top = "0px";
|
||||
}
|
||||
var bounds = this.getExtent();
|
||||
for (var i = 0; i < this.layers.length; i++) {
|
||||
this.layers[i].moveTo(bounds, zoomChanged);
|
||||
this.layers[i].moveTo(bounds, (zoomChanged != null));
|
||||
}
|
||||
this.events.triggerEvent("move");
|
||||
if (zoomChanged)
|
||||
this.events.triggerEvent("zoomend");
|
||||
if (zoomChanged != null)
|
||||
this.events.triggerEvent("zoomend",
|
||||
{oldZoom: zoomChanged, newZoom: this.zoom});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -286,8 +287,7 @@ OpenLayers.Map.prototype = {
|
||||
if (zoom >= 0 && zoom <= this.getZoomLevels()) {
|
||||
var oldZoom = this.zoom;
|
||||
this.zoom = zoom;
|
||||
this.moveToNewExtent(true);
|
||||
this.events.triggerEvent("zoomend", {oldZoom: oldZoom, newZoom: this.zoom});
|
||||
this.moveToNewExtent(oldZoom);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -303,7 +303,7 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
zoomExtent: function() {
|
||||
var fullExtent = this.getFullExtent();
|
||||
|
||||
var oldZoom = this.zoom;
|
||||
this.zoom = this.getZoomForExtent( fullExtent );
|
||||
this.setCenter(
|
||||
new OpenLayers.LatLon(
|
||||
@@ -311,8 +311,6 @@ OpenLayers.Map.prototype = {
|
||||
(fullExtent.minlon+fullExtent.maxlon)/2
|
||||
)
|
||||
);
|
||||
this.moveToNewExtent(true);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -337,8 +335,7 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
defaultDblClick: function (evt) {
|
||||
var newCenter = this.getLatLonFromPixel( evt.xy );
|
||||
this.zoomIn();
|
||||
this.setCenter(newCenter);
|
||||
this.setCenter(newCenter, this.zoom + 1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user