Google maps fits bound in fullscreen

447 Views Asked by At

I have a problem with Google Maps in fullscreen : when it needs to fit the bounds of markers it works in the small div, but in fullscreen it fits like it was in the small div again.

What I need is that it "zooms in to fits bounds" when I go fullscreen, and it "zooms out to fits bounds" when I go back in small div.

Is there anything possible to do ?

Here is an example : https://jsfiddle.net/cmjcs5eL/

function updateBounds() {
    map.fitBounds(bounds);
}

Thank you

1

There are 1 best solutions below

1
On

You need an event listener for when the window is resized:

google.maps.event.addDomListener(window, 'resize', updateBounds);