Leafletjs map - map.invalidateSize is not working

前端 未结 2 780
温柔的废话
温柔的废话 2021-01-08 00:14

I use Leafletjs with google map tiles in my application. Here is my HTML markup:

2条回答
  •  旧巷少年郎
    2021-01-08 00:29

    Thanks Yehoshaphat. I did not want a full screen map. I just wanted to expand the map a little bit.

    Finally, I got it working using the below code:

    $.expandMap = function()    {
        if ($(".rightNav").is(':visible')){
                $(".map-wrap").animate({width:'70%'},'400');
                $(".rightNav").hide(0);
                setTimeout(function(){ map.invalidateSize()}, 400);
            }
     }
    

    The map now expands to fill the expanded space of the outer container. It is not very smooth; but it works.

提交回复
热议问题