Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:45:06+00:00 2026-06-01T01:45:06+00:00

I have a simple page layout with two divs–one on top, and one on

  • 0

I have a simple page layout with two divs–one on top, and one on the bottom. The div on the bottom is where I want my Google map to load. I want the map to fill the bottom div and resize automatically when the window is resized.

I have a bit of script that adjusts the height of the div as well. It works fine, but for some reason there are 29 “mystery pixels” that I have to subtract from the overall height to make everything work right.

Any idea where those mystery pixels are coming from? I used Chrome’s DOM inspector but couldn’t find any clues.

Here’s the HTML on the page:

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
    <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css"
        rel="stylesheet" type="text/css" />
    <link href="css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="js/jquery.loadmask.min.js"></script>
    <script type="text/javascript" src="js/map.js"></script>
</head>
<body style="height: 0px !important">
    <div id="search" style="margin-left: 8px; font-family: Arial, Helvetica, sans-serif; font-size: small">
        <h3>
            New Districts for the 2012 Election</h3>
        <p>
            Enter your home address including street address, city and zip code in the boxes
            below and press the Find My District button. Once you have completed the search,
            click on the map to display district information. For information about how redistricting
            may affect you, please go to <a href="http://www.leg.wa.gov/LIC/Documents/EducationAndInformation/Redistricting%20Information%20for%20Voters.pdf"
                target="_blank">Redistricting Information for Voters</a> (PDF file).
        </p>
        <p>
            Address:
            <input id="Address" type="text" />
            City:
            <input id="City" type="text" />
            State:
            <input id="State" type="text" disabled="disabled" value="WA" style="width: 25px" />
            Zip:
            <input id="Zip" type="text" style="width: 50px" />
        </p>
        <p>
            District Type:
            <input type="radio" id="legislativeLayer" name="legislativeLayer" checked="checked"
                onclick="Map.setLayer()" />Legislative
            <input type="radio" id="congressionalLayer" name="legislativeLayer" onclick="Map.setLayer()" />Congressional
            &nbsp;
            <input type="submit" value="Find My District" onclick="Map.codeAddress()" />
        </p>
    </div>
    <div id="map_canvas" />
</body>
</html>

Here’s the relevant script:

// Initialize the map
initialize: function () {
    // Resize the map to fit the window

    Map.resizeMapDiv();
    $(window).resize(Map.resizeMapDiv);
},

// Resizes the height of the map div so it fits the window
resizeMapDiv: function () {
    $("#map_canvas").height($(window).height() - $("#search").height() - 29);

    // Notify the map a resize has occurred, and center on that point

    google.maps.event.trigger(Map.map, 'resize');

    if (Map.currentPosition)
        Map.map.setCenter(Map.currentPosition);
    else
        Map.map.setCenter(Map.initialPosition);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:45:08+00:00Added an answer on June 1, 2026 at 1:45 am

    Try using jQuery’s offset() method:

    $("#map_canvas").height($(window).height() - $("#map_canvas").offset().top));
    

    The mystery 29px you are encountering is the height of your browsers navigation bar which is included in the $(window).height().

    If you are still finding that the height extends the window size you might have to offset padding/margin as well.

    $("#map_canvas").height($(window).height() - ($("#map_canvas").offset().top + ($("#map_canvas").outerHeight(true) - $("#map_canvas").height())));
    

    Any padding or margins on the body will effect the height also. Make sure these are set to 0px also.

    <body style="padding:0; margin:0;">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple HTML page with svg like this: <div id=plan> <svg xmlns=http://www.w3.org/2000/svg version=1.1>
I have a totally simple layout, in the page is only a silver background
I have a page with a table, and I want its layout to look
I have a simple page with images, and when the user clicks the image,
I am simply learing Ajax with jQuery and have a simple page method that
I have a very simple page with which a user uploads a file. Using
I have a simple django page that has a counter on it. I use
I have a simple aspx page with a few TextBoxes and a submit button.
I have a simple php page that displays data from a mysql database. I
I'm using PeerTracker http://en.wikipedia.org/wiki/PeerTracker to track torrent hashes. I have a simple HTML page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.