I'm currently building a web-app with Angular and OpenLayers. Due to the nature of my site I need to call map.updateSize() when the screen changes size which works as expected.
However when I enter fullscreen using OpenLayers own FullScreen control my maps streches fine but when closing fullscreen it keeps the fullscreen aspect and needs to be updated, hence a call to map.updateSize().
From OL3 ol.control.FullScreen there is an eventlistener on, however I don't know what to bind it to and how to write it. Can anyone provide me with an example, hopefully with the event of closing the fullscreen?
Best Answer
UPDATE: Digging a bit, here's what I've found. If you want to listen on fullscreen you may register the listener on
document
. Now, the event has different name for each browser so to webkit family:And the others:
mozfullscreenchange
,MSFullscreenChange
andfullscreenchange
. Taken from ol-debug.js:A listener would be written like:
But neither fires anything. Have you noticed that Openlayers already do this for you? https://github.com/openlayers/ol3/blob/v3.8.2/src/ol/control/fullscreencontrol.js#L149
Are you using latest version?