Google Maps div not showing up in JSBin

前端 未结 2 1781
迷失自我
迷失自我 2020-12-07 06:29

If I set my width to 500px, I can get the map-canvas div to show up when I click my \"get started\" button. If I set my height/width to 100%, it doesn\'t show up.

I

2条回答
  •  臣服心动
    2020-12-07 06:55

    See Mike Williams explaination of percentage sizing from his Google Maps Javascript API v2 tutorial

    html {
      height:100%;
      width: 100%; 
    }
    body {
      padding-top: 50px;
      padding-bottom: 20px;
      height: 100%;
      width: 100%;
    }
    
    #map-canvas { 
      height: 85%;
      width: 100%;
    }
    

提交回复
热议问题