title: google map Uncaught TypeError: Cannot read property 'offsetWidth' of null
body: <p>this is the source containing googlemap api.
  i'm newbie on the web programming.
  I hardly made this web page. but i faced above error.
  I read many questions regarded this error.
  but i could not fix this error.
  please fix this error.
  thanks.</p>
  
  <pre><code>&lt;html&gt;  
  &lt;head&gt;  
  &lt;title&gt;geocoder&lt;/title&gt;  
  &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"&gt;  
  &lt;/script&gt;  
  &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;  
  &lt;/script&gt;  
  &lt;script type="text/javascript"&gt;  
  
  var kyun ="kyun";
  var map;
  var marker;
  var formated_address2;
  var temp_x;
  var temp_y;
  var value1;
      $(document).ready(function() {   
  
          var latlng = new google.maps.LatLng(37.5640, 126.9751);   
          var myOptions = {   
                zoom : 12,   
                center : latlng,   
                mapTypeId : google.maps.MapTypeId.ROADMAP   
          }   
          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);   
          marker = new google.maps.Marker({   
              position : latlng,    
              map : map   
          });   
  
          var geocoder = new google.maps.Geocoder();   
  
  
  
          google.maps.event.addListener(map, 'click', function(event) {   
              var location = event.latLng;   
              geocoder.geocode({   
                  'latLng' : location   
              },   
              function(results, status){   
                  if( status == google.maps.GeocoderStatus.OK ) {   
                      $('#address').html(results[0].formatted_address);   
                      $('#lat').html(results[0].geometry.location.lat());   
                      $('#lng').html(results[0].geometry.location.lng());
                      value1 = results[0].geometry.location.lat() +',' + results[0].geometry.location.lng();
                  }   
                  else {   
                      alert("Geocoder failed due to: " + status);   
                  }   
              });   
              if( !marker ) {   
                  marker = new google.maps.Marker({   
                      position : location,    
                      map : map
                  });   
              }   
              else {   
                  marker.setMap(null);   
                  marker = new google.maps.Marker({   
                      position : location,    
                      map : map
                  });   
              }   
              map.setCenter(location);   
          });   
      });   
  
  GoogleMap = {
          /* 초기화. */
          initialize : function() {
              this.input = document.getElementById("GoogleMap_input");
              this.address = document.getElementById("GoogleMap_addr");
              this.geocoder = new google.maps.Geocoder();
              this.infowindow = new google.maps.InfoWindow();
  
              //지도 생성.(기본 위치 서울.)
              var latlng = new google.maps.LatLng(37.56641923090,126.9778741551);
              var myOptions = {
                  zoom: 15,
                  center: latlng,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              this.map = new google.maps.Map(
                      document.getElementById("GoogleMap_map"),myOptions);
  
              //마커 생성.
              this.marker = new google.maps.Marker({
                  map : this.map,
                  animation: google.maps.Animation.DROP
              });
          },
          /* 주소 검색.(지오코딩) */
          codeAddress : function() {
              var address = this.input.value;
              //콜백 함수 호출.
              this.geocoder.geocode( { 'address': address}, 
                             function(results, status) {
                  if (status == google.maps.GeocoderStatus.OK) {
                      //검색 된 주소 목록.
                      GoogleMap.address.innerHTML = "";
                      var ul = document.createElement('ul');
                      for(var i=0; i&lt;results.length; i++){
                          var li = document.createElement('li');
                          var a = document.createElement('a');
  
                          a.href = "#" + results[i].geometry.location;
  
  
                          var str_pos = results[i].geometry.location.toString().split(',');
  
                          var x = str_pos[0]
                          x = x.substring(1,x.length).split('.');
                          x = x[0] + '.' + x[1].substring(0,6);
                          temp_x = x;
  
                          var y = str_pos[1]
                          y = y.substring(1,y.length).split('.');
                          y = y[0] + '.' + y[1].substring(0,6);
                          temp_y = y;
  
  
                          value = x+","+y;
                          a.innerHTML = results[i].formatted_address;
                          formated_address2 = results[i].formatted_address;
                          GoogleMap.clickAddress(a, results[i].geometry.location,
                                  results[i].formatted_address);
  
                          li.appendChild(a);
                          ul.appendChild(li);
                      }
                      GoogleMap.address.appendChild(ul);
                  }
              });
          },
          //주소 클릭 이벤트.
          clickAddress : function(a, addr,content){
              a.onmousedown = function(){
                  //지도와 마커이동.
                  /*
                  GoogleMap.map.setCenter(addr);
                  GoogleMap.marker.setPosition(addr);
                  GoogleMap.marker.setAnimation(google.maps.Animation.DROP);
                  GoogleMap.infowindow.setContent(content);
                  GoogleMap.infowindow.open(GoogleMap.map,GoogleMap.marker);
                  */
                  kyun = addr;
              clss.a();
              }
          }
      }
      window.onload = function(){
          GoogleMap.initialize();
      }
  
      function insertText()
  {
    var tempName = window.top.dialogArguments;
    tempName.userName = value1;
    tempName.changeText();
  }
  
  function modalCancel()
  {
    var tempName = window.dialogArguments;
    tempName.changeText(); 
  }
  function parentClose(){
   window.top.close();
  }
  function newWin(){
   window.open("test.html","","");
  }
  function modalclose(){
   self.close();
  }
  
  
  clss = {
      a: function () {  
           map.setCenter(kyun);
           marker.setPosition(kyun);
           marker.setAnimation(google.maps.Animation.DROP);
           $('#address').html(formated_address2);   
           $('#lat').html(temp_x);   
           $('#lng').html(temp_y);
           value1 = temp_x+','+temp_y;
      }
  }
  
  &lt;/script&gt;
  &lt;/head&gt;  
  &lt;body&gt;  
      &lt;table border="1"&gt;  
          &lt;tr&gt;  
              &lt;td colspan="2"&gt;&lt;div id="map_canvas" style="width: 460px; height: 380px;"&gt;&lt;/div&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;  
              &lt;th width="100"&gt;위도&lt;/th&gt;  
              &lt;td id="lat"&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;  
              &lt;th&gt;경도&lt;/th&gt;  
              &lt;td id="lng"&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;     
              &lt;th&gt;주소&lt;/th&gt;  
              &lt;td id="address"&gt;&lt;/td&gt;  
          &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td colspan = "2"&gt;
              &lt;div&gt; 
              &lt;input id="GoogleMap_input" type="textbox" value="" onkeydown="javascript:if(event.keyCode == 13) GoogleMap.codeAddress();"  style='width:365px;'&gt; 
              &lt;input type="button" value="주소검색" onclick="javascript:GoogleMap.codeAddress();"&gt;
              &lt;/div&gt;
              &lt;div id="GoogleMap_addr"&gt;&lt;/div&gt; 
          &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td  style='width:450px;' colspan ="2" align = "center"&gt;
          &lt;TABLE border = "0"&gt;
              &lt;div&gt;
              &lt;tr&gt;
              &lt;td style='width:225px;' align = "center"&gt;
              &lt;INPUT VALUE="취소" TYPE=button onclick="window.close();" style='width:200px;'&gt;&lt;BR&gt;
              &lt;/td&gt;
              &lt;td style='width:225px;' align = "center"&gt;
              &lt;INPUT VALUE="확인" TYPE=button onclick="insertText();window.close();" style='width:200px;'&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
              &lt;/div&gt;
          &lt;/TABLE&gt;
          &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;  
  &lt;/body&gt;  
  &lt;/html&gt; 
  </code></pre>