title: load a new google map in current page with load ajax
body: <p>I try to load a java script google map v3 in my index page with ajax load:</p>
  
  <p>I know it there a lot of same question but I couldn't underestand them.</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
      &lt;html&gt;
        &lt;head&gt;
          &lt;script src="js/vendor/jquery.min.js"&gt;&lt;/script&gt;
          &lt;style type="text/css"&gt;
            html, body { height: 100%; margin: 0; padding: 0; }
            #map { height: 100%; }
          &lt;/style&gt;
        &lt;/head&gt;
        &lt;body&gt;
        &lt;div id="mapc"&gt;&lt;/div&gt;
  
        &lt;span id="btn"&gt;load map&lt;/span&gt;
  
          &lt;script type="text/javascript"&gt;
  
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -34.397, lng: 150.644},
          zoom: 8
        });
      }
  
      $(document).ready(function(){
         $("#btn").click(function(){
          $("#mapc").load("map.php");
          initMap();
          });
       });
          &lt;/script&gt;
          &lt;script async defer
            src="https://maps.googleapis.com/maps/api/js?callback=initMap"&gt;
          &lt;/script&gt;
        &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>Note: I need google API link be in index.php because I plan to have anoher google map in index.php too.</p>
  
  <p>also this is <strong>map.php</strong></p>
  
  <pre><code>&lt;div id="map"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Also in console I only get this error:</p>
  
  <pre><code>js?callback=initMap:74 Uncaught TypeError: Cannot read property 'offsetWidth' of null_.Af @ js?callback=initMap:74_.hg @ js?callback=initMap:81initMap @ (index):19(anonymous function) @ js?callback=initMap:87(anonymous function) @ js?callback=initMap:49_.ac @ js?callback=initMap:46oc @ js?callback=initMap:49(anonymous function) @ js?callback=initMap:123google.maps.Load @ js?callback=initMap:21(anonymous function) @ js?callback=initMap:122(anonymous function) @ js?callback=initMap:123
  js?callback=initMap:74 Uncaught TypeError: Cannot read property 'offsetWidth' of null_.Af @ js?callback=initMap:74_.hg @ js?callback=initMap:81initMap @ (index):19(anonymous function) @ (index):28n.event.dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3
  </code></pre>