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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:48:10+00:00 2026-05-28T07:48:10+00:00

I have a problem loading google map. In my head section I have the

  • 0

I have a problem loading google map. In my head section I have the following code (I have a correct Google API Key)

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=false"></script>
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0; padding: 0 }
  #map_canvas { height: 100% }
</style>
<script type="text/javascript">
    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);
    }
</script>

and my body section starts as follows:

<div class="page">
    <div id="header">
        <div id="title">
            <h1>My MVC Application</h1>
            <div id="map_canvas" style="width: 100%; height: 100%"></div>

This doesn’t work. However when I move the “map_canvas” div just after the body:

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

it all works fine. Can you help me please. Additionally, how can I use jQuery instead of calling initialize method?

  • 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-05-28T07:48:10+00:00Added an answer on May 28, 2026 at 7:48 am

    As Bassam mentioned, you need to set an explicit pixel width and height. Otherwise, take a look at the CSS for page, header, and title elements. The width and height for these elements needs to cascade to the map_canvas element.

    To use jQuery instead of initialize, remove onload="initialize()" from the body element and add the following code above initialize() function:

    $(document).ready(function() {
       initialize();
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing one problem ,that when the google map is loading then there
I have a Google Map (API 2) that used to work fine as a
I have a google map in a page (Using the Javascript API v3) the
I have a problem with loading image with java 2ME. I have a image
I have a problem with the reference of a variable when loading a saved
I am loading some text dynamically into a div, but have the problem that
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have a TWebBrowser component that show a Google maps page. The problem is
I have a strange problem with Google Maps showing differently in IE and the
I have a height problem with Sexy Combo ( google 'Sexy Combo' ), a

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.