How do I create a show full screen button to toggle my google maps page to be full screen?

后端 未结 5 2032
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 08:54

I have a google map integrated on part of my page. I would like to create a toggle button to toggle the map between full screen and normal size. So when you click on it - th

5条回答
  •  梦谈多话
    2020-12-29 09:14

    Now we have a Fullscreen API https://developer.mozilla.org/en/DOM/Using_full-screen_mode you just select the DOM element you want to set to fullscreen and call the fullscreen API on it. Something like this

    var elem = document.getElementById("myvideo");
    if (elem.requestFullScreen) {
      elem.requestFullScreen();
    } else if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullScreen) {
      elem.webkitRequestFullScreen();
    }
    

提交回复
热议问题