how to make leaflet map height variable

前端 未结 4 1444
旧巷少年郎
旧巷少年郎 2021-02-03 20:05

In my Application I was making div of map as

but to make my map responsi

4条回答
  •  爱一瞬间的悲伤
    2021-02-03 20:40

    Put a position: relative wrapper parent around it, then position your map absolutely to fill that parent:

    .map-wrapper {
      position: relative;
    }
    
    #map {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
    }
    
    

    If #map already has a parent that you can position relatively, just use that; you won't need the .map-wrapper element.

    Leaflet Quick Start Guide could be clearer on this point as it's a common use case. The mobile tutorial hints at it.

提交回复
热议问题