Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Google Maps Container DIV width and height 100%

I loaded Google Maps API v3 and print Google Map in div. But when set width & height to 100% and auto I can't see the Map.

Here is HTML code snippet.

<!-- Maps Container --> <div id="map_canvas" style="height:100%;width:100px;margin:0 auto;"></div> 

Is there a way to fix this issue?

like image 556
BBKing Avatar asked Apr 18 '12 12:04

BBKing


People also ask

How do I make HTML map full screen?

In the below example, applying style="height: 100%;" to the body and html makes google maps full height because the div the map loads in to is a child of body . In your case, you need to add style="height: 100%;" to the relevant parent elements of #map .


1 Answers

You have to set all parent containers to a 100% width if you want to cover the whole page with it. You have to set an absolute value at width and height for the #content div at the very least.

body, html {   height: 100%;   width: 100%; }  div#content {   width: 100%; height: 100%; } 
like image 198
Machiel Avatar answered Sep 18 '22 15:09

Machiel