I'm getting this error when trying to display Google Maps on my page. "JavaScript runtime error: Unable to get property 'offsetWidth' of undefined or null reference"
Its coming from the Javascript function initialize() from the line var map = new google.maps.Map(document.getElementById("map-canvas")
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);
Here is my html
<div id="map-canvas">
<h2>hello</h2>
</div>
and here is my css
#map-canvas {
position: fixed;
top: 41px;
left: 0;
bottom: 0;
width: 40%;
height: 100%;
background-color: pink;
/*border: 3px solid black;*/
}