Google Maps V3, Map won't display when wrapped in a second div

前端 未结 2 1511
孤独总比滥情好
孤独总比滥情好 2020-12-21 19:54

I am a newbie to Google Maps. I have started with their \"Hello World\" code, which has the following:


相关标签:
2条回答
  • 2020-12-21 20:11

    Apply width and height to div:

    <div style="width:100%; height:100%;">
       <div id="map_canvas" style="width:100%; height:100%"></div>
    </div>
    

    Inner div's ( id="map_canvas" div ) sizes are set by percents. This means inner div will be fit to its parent sizes.

    0 讨论(0)
  • 2020-12-21 20:22

    Check if the SCRIPT src URL starts with http://. I spent about half a day de-bugging to realize this.

    Earlier...

    <script src="//maps.google.com/maps?file=api&amp;v=2&amp;key....
    

    Now

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key....
    

    It works on local now...

    0 讨论(0)
提交回复
热议问题