diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index d67030aa2c..bf153b41c2 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -167,6 +167,8 @@ OpenLayers.Control.PanZoomBar.prototype = this.mouseDragStart = evt.xy.clone(); this.zoomStart = evt.xy.clone(); this.div.style.cursor = "move"; + // reset the div offsets just in case the div moved + this.zoomBarDiv.offsets = null; OpenLayers.Event.stop(evt); }, diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 2f86218672..816ee5399b 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -179,12 +179,13 @@ OpenLayers.Map.prototype = { this.viewPortDiv.appendChild(this.layerContainerDiv); this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES, this.fallThrough); - this.updateSize(); - // Because Mozilla does not support the "resize" event for elements other - // than "window", we need to put a hack here. - // + // update the map size and location before the map moves + this.events.register("movestart", this, this.updateSize); + + // Because Mozilla does not support the "resize" event for elements other + // than "window", we need to put a hack here. if (navigator.appName.contains("Microsoft")) { // If IE, register the resize on the div this.events.register("resize", this, this.updateSize); @@ -633,6 +634,8 @@ OpenLayers.Map.prototype = { * "onresize" for an element) */ updateSize: function() { + // the div might have moved on the page, also + this.events.element.offsets = null; var newSize = this.getCurrentSize(); var oldSize = this.getSize(); if (oldSize == null) @@ -646,9 +649,6 @@ OpenLayers.Map.prototype = { for(var i=0; i < this.layers.length; i++) { this.layers[i].onMapResize(); } - - // the div might have moved on the page, also - this.events.element.offsets = null; if (this.baseLayer != null) { var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);