Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap fullscreen google maps with navbar

I have a full screen google map application with a navbar on the top.

So i have a setup like this:

<div class="navbar">
    <nav bar stuff......>
</div>
<div id="mapcanvas"></div>

with the mapcanvas element having height and width to be 100%.

However, the mapcanvas seems to overflow out the page and the the entire page could scroll down the page by the amount of the navbar.

How would i go about fixing that?

like image 778
Pwnna Avatar asked Jan 01 '13 19:01

Pwnna


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 .

How do I add a map to my footer?

You can also add Google Maps to your site's widget section, like the sidebar or footer. To start, head over to Appearance » Widgets from your WordPress admin panel. Next, click the '+' button and add the 'AIOSEO Local – Map' widget block where you'd like to display your location.


1 Answers

Maybe try adding navbar-fixed-top to your navbar class.

<div class="navbar navbar-fixed-top">
    <nav bar stuff......>
</div>

If you don't want the navbar to be over the map set the #mapcanvas as this (works till IE7 - haven't tried ie6)

html,body {width:100%;height:100%;margin:0;padding:0;}

#mapcanvas {
    background:red;display: block;
    position:absolute;
    height:auto;
    bottom:0;
    top:0;
    left:0;
    right:0;
    margin-top:50px; /* adjust top margin to your header height */
}
<div id="mapcanvas">asdf</div>
like image 198
easwee Avatar answered Sep 23 '22 22:09

easwee