Set up a resize event listener to call map.updateSize() as necessary.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@262 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Schuyler Erle
2006-05-22 14:08:15 +00:00
parent 27c99baacb
commit 0cc4aa316d
2 changed files with 7 additions and 4 deletions

View File

@@ -5,7 +5,8 @@ OpenLayers.Events.prototype = {
BROWSER_EVENTS: [ BROWSER_EVENTS: [
"mouseover", "mouseout", "mouseover", "mouseout",
"mousedown", "mouseup", "mousemove", "mousedown", "mouseup", "mousemove",
"click", "dblclick" "click", "dblclick",
"resize", "focus", blur"
], ],
// hash of Array(Function): events listener functions // hash of Array(Function): events listener functions

View File

@@ -85,10 +85,14 @@ OpenLayers.Map.prototype = {
this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES); this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
this.updateSize();
// update the internal size register whenever the div is resized
this.events.register("resize", this, updateSize);
this.layers = []; this.layers = [];
if (!this.controls) { if (!this.controls) {
this.controls = []; this.controls = [];
this.addControl(new OpenLayers.Control.MouseDefaults(), null ); this.addControl(new OpenLayers.Control.MouseDefaults(), null );
this.addControl(new OpenLayers.Control.PanZoom(), this.addControl(new OpenLayers.Control.PanZoom(),
new OpenLayers.Pixel(4,4) ); new OpenLayers.Pixel(4,4) );
@@ -96,8 +100,6 @@ OpenLayers.Map.prototype = {
this.popups = new Array(); this.popups = new Array();
this.updateSize();
// always call map.destroy() // always call map.destroy()
Event.observe(window, 'unload', Event.observe(window, 'unload',
this.destroy.bindAsEventListener(this)); this.destroy.bindAsEventListener(this));