Daniele
Daniele

Reputation: 203

HTML Page don't show google map

I have a simple HTML page and I want to display a google map using API Access. I use this code:

    <!DOCTYPE html><!-- HTML5 -->
<html lang="it" dir="ltr">
    <head>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=blablabla&sensor=true">
        </script>
        <script type="text/javascript">
          function initialize() {
            var mapOptions = {center: new google.maps.LatLng(-34.397, 150.644), zoom: 8};
            var map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);
          }
          google.maps.event.addDomListener(window, 'load', initialize);
        </script>
    </head>
    <body>
        <div id="map-canvas"/>
    </body>
</html>

I'm sure that the script block is processed, but the page don't show the map.

Can you help me?

Upvotes: 3

Views: 1635

Answers (2)

radiopassive
radiopassive

Reputation: 566

//In the head section place these styles

<head>
<style>
  html{
    height:100%;
   }
   body{
    margin: 0;
    padding: 0;
    height:100%;
   }
</style>
</head>

//In the body of your document, define the style of the map_canvas as such:

<body>
 <div id="map_canvas" style="height:100%;"></div>

</body>

//right click you document and select insepct element. select the console tab in developers //tools. If no error is shown in there, then this might fix your problem //Best of luck 8-)

Upvotes: 3

Sridhar R
Sridhar R

Reputation: 20418

Try this

First include Jquery library in your section (before google js file)

<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>

Upvotes: 0

Related Questions