0

I am having an issue initializing a map in the page. The code within my body tags is shown below:

<body>
      <div class="outer">
            <div class="header">
            </div>
            <div class="main">
                  <div id="map_canvas">
                  </div>
            </div>
            <div class="footer">
            </div>
              </div>
</body>

When I initialise the function on the main class, the map displays properly.

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

However when the map is initialised as shown below, it does not display at all on the page.

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

I am not sure what is causing this or how to fix it. Any help is greatly appreciated.

1 Answer 1

1

Your map_canvas div needs to have its id set to "map_canvas" also be sure that the css for map_canvas div is set to have a width and height.

Sign up to request clarification or add additional context in comments.

1 Comment

sorry that was a mistake in my typing, the div had its id set to map_canvas. However, I had not set a width and height on it. This worked. Thanks for you help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.