Cannot set map's div height for openlayers map

前端 未结 5 1393
予麋鹿
予麋鹿 2021-01-05 23:25

This code make the map\'s div width max but height to 0 (the % value doesn\'t matter, it\'s always 0)

5条回答
  •  孤街浪徒
    2021-01-05 23:58

    This is my fix:

    function fixContentHeight(){
        var viewHeight = $(window).height();
        var header = $("div[data-role='header']:visible:visible");
        var navbar = $("div[data-role='navbar']:visible:visible");
        var content = $("div[data-role='content']:visible:visible");
        var contentHeight = viewHeight - header.outerHeight() - navbar.outerHeight();
        content.height(contentHeight);
        map.updateSize();
    }
    

提交回复
热议问题