Leaflet Map not showing in bootstrap div

前端 未结 4 582

This is a super odd problem that I can not figure out. I have my div with the map and its css styling. The Leaflet map is showing up in one rectangle and not in the div. Its

相关标签:
4条回答
  • 2020-12-11 18:34

    Execute the following function once the map is opened:

    map.invalidateSize();
    

    This will fix your problem.

    0 讨论(0)
  • 2020-12-11 18:37

    This worked for me,

    $('#showTravel').on('shown.bs.modal', function (e) {
      //creation of map
    })
    

    Or search in event of showing the div and into function creating the map

    0 讨论(0)
  • 2020-12-11 18:40

    I used it with hided divs, which appear after a click. The tiles were also not visible, so I added map.invalidateSize() to the jQuery function where the div is set visible. Hope that helps...

    0 讨论(0)
  • 2020-12-11 18:47

    I have the same issue to display map inside Bootstrap Tabs. I have fixed it by using -

     $('#gmap').on('shown.bs.tab', function (e) {
        //clear map first
        clearMap();
        //resize the map
       map.invalidateSize(true);
       //load the map once all layers cleared
       loadMap();
    })
    
    0 讨论(0)
提交回复
热议问题