update map resize functionality to deal with google layer. if ve had a similar checkResize() function, then we would be able to safely resize an OL map with a ve layer in it as well. unfortunately, this is not the case. a bug report i am gonna file
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1275 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -148,6 +148,12 @@ OpenLayers.Layer.prototype = {
|
||||
Object.extend(this, this.options);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
onMapResize: function() {
|
||||
//this function can be implemented by subclasses
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bound
|
||||
|
||||
@@ -147,6 +147,13 @@ OpenLayers.Layer.Google.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
onMapResize: function() {
|
||||
this.gmap.checkResize();
|
||||
},
|
||||
|
||||
/** If we can't load the GMap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
|
||||
@@ -148,7 +148,7 @@ OpenLayers.Map.prototype = {
|
||||
Event.observe(window, 'resize',
|
||||
this.updateSize.bindAsEventListener(this));
|
||||
}
|
||||
|
||||
|
||||
//set the default options
|
||||
this.setOptions(options);
|
||||
|
||||
@@ -470,14 +470,18 @@ OpenLayers.Map.prototype = {
|
||||
if (oldSize == null)
|
||||
this.size = oldSize = newSize;
|
||||
if (!newSize.equals(oldSize)) {
|
||||
// move the layer container so that the map is still centered
|
||||
var dx = (newSize.w - oldSize.w) / 2,
|
||||
dy = (newSize.h - oldSize.h) / 2;
|
||||
var lcStyle = this.layerContainerDiv.style;
|
||||
lcStyle.left = (parseInt(lcStyle.left) + dx) + "px";
|
||||
lcStyle.top = (parseInt(lcStyle.top ) + dy) + "px";
|
||||
// reset the map center
|
||||
this.layerContainerOrigin = this.center.clone();
|
||||
|
||||
//notify layers of mapresize
|
||||
for(var i=0; i < this.layers.length; i++) {
|
||||
this.layers[i].onMapResize();
|
||||
}
|
||||
|
||||
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
|
||||
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
this.setCenter(center, zoom);
|
||||
|
||||
// store the new size
|
||||
this.size = newSize;
|
||||
// the div might have moved on the page, also
|
||||
|
||||
Reference in New Issue
Block a user