"Switching between google layers after map resize", after map size change, as

is used by mapfish and others, the google map can get confused as to its size
and not resize correctly. This patch changes that so that the check happens on
moveTo, so we know if the map has resized. The checkResize is a cheap call in
the default case. r=me, patch by gregers, (Closes #1797)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@8990 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-03-10 18:07:53 +00:00
parent 4a4cc13e86
commit 10bc8f5726

View File

@@ -190,13 +190,25 @@ OpenLayers.Layer.Google = OpenLayers.Class(
* evt - {Event}
*/
onMapResize: function() {
this.windowResized = true;
if(this.visibility) {
this.mapObject.checkResize();
} else {
this.windowResized = true;
this.checkResize();
}
},
/**
* APIMethod: checkResize
* Check if the map has been resized, and if the Google Maps object is ready for checkResize.
* If the mapObject.getSize() equals the layer div's offset size, or if mapObject.getCenter()
* is null, the mapObject.checkResize() will fail.
*/
checkResize: function() {
if (this.windowResized && this.div.style.display != "none" && this.mapObject.getCenter()) {
this.mapObject.checkResize();
this.windowResized = false;
}
},
/**
* Method: display
* Hide or show the layer
@@ -206,10 +218,22 @@ OpenLayers.Layer.Google = OpenLayers.Class(
*/
display: function(display) {
OpenLayers.Layer.EventPane.prototype.display.apply(this, arguments);
if(this.div.style.display == "block" && this.windowResized) {
this.mapObject.checkResize();
this.windowResized = false;
}
this.checkResize();
},
/**
* Method: moveTo
* Handle calls to move the layer.
*
* Parameters:
* bound - {<OpenLayers.Bounds>}
* zoomChanged - {Boolean} Tells when zoom has changed, as layers have to
* do some init work in that case.
* dragging - {Boolean}
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
this.checkResize();
},
/**