[OpenLayers-Users] resize map div when onresize event occurs in body causing Google Maps issues

Mike Quentel mikequentel at yahoo.com
Mon May 14 13:52:27 EDT 2007


This code resizes the map div (specifically, its height) when the onresize event gets called on the body of the page.  Problem is that Google Maps layer now has issues when user attempts to pan (attempting to pan resets the map extents to geographic areas far, far away from the original extent--nowhere near the intended mouse movement).

var winW = screen.width;
var winH = screen.height;
function calculateBrowserWindow() {
  if (parseInt(navigator.appVersion) > 3) {
    if (navigator.appName == "Netscape") {
      winW = window.innerWidth;
      winH = window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft") != -1) {
      winW = document.body.offsetWidth;
      winH = document.body.offsetHeight;
    }
  }
}
var mapWindowHeight = winH - 44 - 112;
function setMapWindow() {
  calculateBrowserWindow();
  mapWindowHeight = winH - 44 - 112;
    var mapDivReference = document.getElementById("mapDiv");
    if (mapDivReference != null) {
      mapDivReference.style.height = mapWindowHeight;
    } 
} 

<BODY topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 onresize="setMapWindow();">

Now, I just found this reference to map.updateSize() : http://openlayers.org/pipermail/trac/2007-March/000859.html

Will calling map.updateSize() solve the panning issue, or am I missing something else as well in this code?

Thank you.

Mike Quentel





      ___________________________________________________________ 
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html 



More information about the Users mailing list