title: Google map TypeError: a is null
body: <p>I have to use google maps for my web application. The problem is I get an error that says TypeError: a is null. Here is how I call google map on window load:</p>
  
  <p> </p>
  
  <pre><code>var lat;
  var long;
  var map;
  
  function geoloc() {//on window load get the user latitude and longitue and pass the values to   "successPosition" function if user allow the geolocation other wise call   "showError" function to gave static latitude and longitude.   
  
  
      if (navigator.geolocation) {
          var optn = {
              enableHighAccuracy: true,
              timeout: 0,
              maximumAge: 0
          };
  
          navigator.geolocation.getCurrentPosition(successPosition, showError, optn);
  
      } else {
          alert('Geolocation is not supported in your browser');
      }
  }
  
  function successPosition(position) {  //get the latitude and longitude by geolocation function
  
  
      lat = position.coords.latitude; 
      long = position.coords.longitude;
  
      initialize(lat, long);//calling the initialize function
  }
  
  function initialize(lat, long) {   //initialize the map 
  
      var myLatlng = new google.maps.LatLng(lat, long);
  
      var mapOptions = {//maps options the zoom level and map center
          zoom: 4,
          center: myLatlng
  
      }
  
      map = new google.maps.Map(document.getElementById('googleMap'), mapOptions);
  
  
      var marker = new google.maps.Marker({//create the marker on the map
          position: myLatlng,
          map: map,
          title: 'Hello World!'
      });
  }
  
  
  function showError() {//pass the values to "initialize" function if the user dosn't allow the geolocation 
  
      initialize(31.5497, 74.3436);
  }
  google.maps.event.addDomListener(window, 'load', geoloc);//on window load calls the geoloc function to get the user latitude and longitud 
  </code></pre>
  
  <p>When I run this on Firefox, Firebug tells me "TypeError: a is null".I don't have the slightest clue on how to fix it. Please help! </p>