I'm currently using Leaflet along with leaflet.fullscreen to provide a full screen map.

I've got it working nicely with the button but I can't work out how to "call" the function manually from my JavaScript code.

I've tried: map.fullscreenControl.toogleFullScreen(); but get the following error and a "broken" fullscreen:

TypeError: this.invalidateSize is not a function
  • Typo?? map.fullscreenControl.**toggleFullScreen**(); – Vic Mar 25 '19 at 11:33

You could trigger a click on its fullscreen button. For example with jQuery:

  • Recent Browsers won't let you do that. IE: Chrome would say: "Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture." – augusto Mar 20 '20 at 20:42

With no answers and still struggling I switched to a different plugin Leaflet.fullscreen .

It seems a lot more straightforward, however I did need to tweek the CSS for < IE9.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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