"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:
@@ -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();
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user