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

后端 未结 5 2020
伪装坚强ぢ
伪装坚强ぢ 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:29

    Here's a jQuery implementation.

    $("#map_toggler").click(function() {
      $("#map").toggleClass("fullscreen")
    });
    

    In the CSS:

    #map {
      width: 400px;
      height: 200px;
    }
    
    #map.fullscreen {
      position: fixed;
      width:100%;
      height: 100%;
    }
    

    Untested, but something along the lines of that should work.

提交回复
热议问题