Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a web page that contains a button to set the map full screen and back to its normal form, the problem map doesn't set to full screen until I resize the output window, how to overcome this,

Any guidance and help is appreciated.

Here is the working example: Demo

share|improve this question
up vote 8 down vote accepted

Add map.updateSize(); to the end of $("#btn-full-screen").click...


updateSize documentation

This function should be called by any external code which dynamically changes the size of the map div (because mozilla wont let us catch the “onresize” for an element)

share|improve this answer
Thanks it worked. – bios Sep 5 '12 at 4:00

You can use OpenLayers.Map.updateSize method to redraw your base Layer when you maximize the map.

So, adding a function like:

var fullScreen = function () {

you would only need to add an additional option to your map:

var map = new OpenLayers.Map({
    div: "map",
    center: new OpenLayers.LonLat(0, 0),
    updateSize: fullScreen,
    minResolution: "auto",
    minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
    maxResolution: "auto",
    maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
    projection: Mercator,
    displayProjection: Geographic

Good luck!

share|improve this answer
It doesn't set map to full screen, can you please update the fiddle. – bios Sep 4 '12 at 8:57
Thanks. I had tiles becoming white when zooming using transitionEffect: 'resize'. map.baseLayer().redraw(); fixed it. – Nicolas Boisteault Jan 6 at 15:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.