title: TypeError: g is undefined Google Map API
body: <p>I'm using Google map API. My application should work in following manner:</p>
  
  <ul>
  <li>user clicks Google Map a form opens in infoWindow </li>
  <li>On clicking next another form should open exactly on same coordinates
  Problem is here, i am unable to open 2nd form on this location and getting following error</li>
  </ul>
  
  <blockquote>
    <p>TypeError: g is undefined Source File:
    <a href="https://maps.googleapis.com/maps-api-v3/api/js/22/14/infowindow.js" rel="nofollow">https://maps.googleapis.com/maps-api-v3/api/js/22/14/infowindow.js</a>
    Line: 8</p>
  </blockquote>
  
  <p>below is my code &amp; i believe problem is somewhere here </p>
  
  <blockquote>
    <p>infowindowtwo.open(map, newmarker);</p>
  </blockquote>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var marker;
      var infowindow;
      var infowindwotwo;
  
     function initialize() {
        var latlng = new google.maps.LatLng(37.4419, -122.1419);
        var options = {
          zoom: 13,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(document.getElementById("map"), options);
  
  
        var html = "&lt;table&gt;" +
                   "&lt;tr&gt;&lt;td&gt;Name:&lt;/td&gt; &lt;td&gt;&lt;input type='text' id='name'/&gt; &lt;/td&gt; &lt;/tr&gt;" +
                   "&lt;tr&gt;&lt;td&gt;Address:&lt;/td&gt; &lt;td&gt;&lt;input type='text' id='address'/&gt;&lt;/td&gt; &lt;/tr&gt;" +
                    "&lt;tr&gt;&lt;td&gt;hidden:&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='aa' id='latlong' /&gt;&lt;/td&gt; &lt;/tr&gt;" +
                   "&lt;tr&gt;&lt;td&gt;Type:&lt;/td&gt; &lt;td&gt;&lt;select id='type'&gt;" +
                   "&lt;option value='bar' SELECTED&gt;bar&lt;/option&gt;" +
                   "&lt;option value='restaurant'&gt;restaurant&lt;/option&gt;" +
                   "&lt;/select&gt; &lt;/td&gt;&lt;/tr&gt;" +
                   "&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='button' id='btnone' value='Next' onclick='phasetwo()'/&gt;&lt;/td&gt;&lt;/tr&gt;";
  
      infowindow = new google.maps.InfoWindow({
       content: html
      });
        google.maps.event.addListener(map, "click", function(event) {
       //making marker here
          marker = new google.maps.Marker({
            position: event.latLng,
            map: map
          });
        google.maps.event.addListener(marker, "click", function() {
               $("#test").val(event.latLng);
               infowindow.open(map, marker);
          });
      });
    }
  //-------------------------------------------------------------------------
      function phasetwo()
      {
          alert(123);
           var testp = $("#test").val();
           alert(testp);
           var htmltwo = "&lt;table&gt;" +
                   "&lt;tr&gt;&lt;td&gt;Name2:&lt;/td&gt; &lt;td&gt;&lt;input type='text' id='name'/&gt; &lt;/td&gt; &lt;/tr&gt;" +
                   "&lt;tr&gt;&lt;td&gt;Type2:&lt;/td&gt; &lt;td&gt;&lt;select id='type'&gt;" +
                   "&lt;option value='bar' SELECTED&gt;bar&lt;/option&gt;" +
                   "&lt;option value='restaurant'&gt;restaurant&lt;/option&gt;" +
                   "&lt;/select&gt; &lt;/td&gt;&lt;/tr&gt;" +
                   "&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='button' value='Save ' onclick='phasetwo()'/&gt;&lt;/td&gt;&lt;/tr&gt;";
  
  
                  infowindowtwo = new google.maps.InfoWindow({
                   content: htmltwo
                  });
  
                  var newmarker = new google.maps.Marker({
                  position: testp,
                  map: map,
                  title: htmltwo
              });
          infowindow.close();
              //  infowindowtwo.open(map, newmarker);
                  alert(2);
              infowindowtwo.open(map, newmarker);
                  alert(3);
          // marker.push(newmarker);
          }
  
     function saveData() {
        var name = escape(document.getElementById("name").value);
        var address = escape(document.getElementById("address").value);
        var type = document.getElementById("type").value;
        var latlng = marker.getPosition();
  
        var url = "phpsqlinfo_addrow.php?name=" + name + "&amp;address=" + address +
                  "&amp;type=" + type + "&amp;lat=" + latlng.lat() + "&amp;lng=" + latlng.lng();
        downloadUrl(url, function(data, responseCode) {
          if (responseCode == 200 &amp;&amp; data.length &gt;= 1) {
            infowindow.close();
            document.getElementById("message").innerHTML = "Location added.";
          }
        });
      }
  
      function downloadUrl(url, callback) {
        var request = window.ActiveXObject ?
            new ActiveXObject('Microsoft.XMLHTTP') :
            new XMLHttpRequest;
  
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            request.onreadystatechange = doNothing;
            callback(request.responseText, request.status);
          }
        };
      request.open('GET', url, true);
        request.send(null);
      }
    function doNothing() {}
      &lt;/script&gt;
  </code></pre>
  
  <p>Thank you.</p>