make updateSize not call setCenter if map has no center, and remove unused code, r=tschaub (closes #2105) (closes #2114)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9587 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1343,12 +1343,12 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
this.layers[i].onMapResize();
|
||||
}
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
|
||||
var centerLL = this.getLonLatFromViewPortPx(center);
|
||||
var center = this.getCenter();
|
||||
|
||||
if (this.baseLayer != null && center != null) {
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
this.setCenter(this.getCenter(), zoom);
|
||||
this.setCenter(center, zoom);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1313,7 +1313,39 @@
|
||||
|
||||
map.destroy();
|
||||
t.ok(!map.panTween || !map.panTween.playing, "the map pan tween is not playing after destroy");
|
||||
}
|
||||
|
||||
function test_updateSize(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map, moveToCnt, size;
|
||||
|
||||
map = new OpenLayers.Map({div: "map"});
|
||||
map.addLayer(new OpenLayers.Layer("layer", {isBaseLayer: true}));
|
||||
|
||||
map.moveTo = function() {
|
||||
moveToCnt++;
|
||||
OpenLayers.Map.prototype.moveTo.apply(this, arguments);
|
||||
};
|
||||
|
||||
map.getCurrentSize = function() {
|
||||
return size;
|
||||
};
|
||||
|
||||
// map has no center
|
||||
// 1 test
|
||||
moveToCnt = 0;
|
||||
size = new OpenLayers.Size(650, 350);
|
||||
map.updateSize();
|
||||
t.eq(moveToCnt, 0, "updateSize doesn't move the map if it doesn't have a center");
|
||||
|
||||
// map has a center
|
||||
// 1 test
|
||||
map.zoomToMaxExtent();
|
||||
moveToCnt = 0;
|
||||
size = new OpenLayers.Size(600, 300);
|
||||
map.updateSize();
|
||||
t.eq(moveToCnt, 1, "updateSize move the map if it has a center");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user