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 7967825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:58:57+00:00 2026-06-04T06:58:57+00:00

I am a newbie in javascript and I need your help on setting a

  • 0

I am a newbie in javascript and I need your help on setting a google map to div element which is within another div element. Here’s the code which works if the div elements aren’t nested:

function initialize() {

var myOptions = {
    center: new google.maps.LatLng(-34.397, 150.644),
    zoom: 8,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);

However if I have nested divs, it doesn’t work:

<body onload="initialize()">
<div id="main">
    <div id="map_canvas" style="width:100%; height:100%"></div>
</div>
</body>

How do I solve this problem?

  • 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-04T06:58:58+00:00Added an answer on June 4, 2026 at 6:58 am

    After a bit of testing, I concluded that you need to set a height to your id="main" div also

    style="width:100%; height:100%"

    Because it’s a container to the map, and without a defined height nothing will appear. It’s like rolling down a curtain, the map won’t push it down by itself.

    I’m assuming you have something similar already too since the map works without nesting, but I’ll mention it again:

    <style type="text/css">
      html, body {height:100%}
    </style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im a javascript newbie and would need some help with this simple thing... I
I'm a newbie in Jquery Ajax. I need your help. I want to display
I am a total newbie to JavaScript and jQuery, and need some help. Also
Javascript newbie here, just trying to tweak this bit of code. It checks for
Newbie in javascript.. Need a little help. I have a SPAN or IMG that
JavaScript newbie here, I was going through some js code at work when i
i need help with a little code that i have below. i'm a newbie
I am a newbie with JavaScript and I feel the unresistible need to strong
Javascript newbie here, trying to load Twitter profile images using the URLs returned by
I am basically a newbie with javascript. I want to populate a div in

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.