title: Uncaught InvalidValueError: initMap is not a function
body: <p>I am trying to load a google map with some specific parmeters. I understand the problem is most likely that the initMap function needs to be declared globally. 
  However, I have no idea how, even after searching a number of StackOverflow post with similar problems.</p>
  
  <p>The rest</p>
  
  <pre><code> &lt;script&gt;
   var databaseArray = [{id: 'BTS1', arfcn: '70', bsic: '29'}
  ,{id: 'BTS2', arfcn: '60', bsic: '28'}
  ,{id: 'BTS3', arfcn: '65', bsic: '27'}
  ,{id: 'BTS4', arfcn: '55', bsic: '26'}
  ,{id: 'BTS5', arfcn: '75', bsic: '29'}];
  
  var locationArray = [{lat: '60.78064', lng: '10.67037'}
  ,{lat: '60.76978', lng: '10.66677'}
  ,{lat: '60.76991', lng: '10.69672'}
  ,{lat: '60.78889', lng: '10.68462'}
  ,{lat: '60.76086', lng: '10.65141'}];
  
  
  function displayDatabase(){
    var table1 = document.getElementById('database');
    for (var i = 0; i &lt; databaseArray.length; i++){
        var bts = databaseArray[i];
        var row = document.createElement('tr');
        var properties = ['id', 'arfcn', 'bsic'];
  
        for(var j = 0; j &lt; properties.length; j++){
            var cell = document.createElement('td');
            cell.innerHTML = bts[properties[j]];
            row.appendChild(cell);
        }
        table1.appendChild(row);
    }
   }
  
  function displayLocations(){
     var table2 = document.getElementById('location');
     for (var i = 0; i &lt; locationArray.length; i++){
        var location = locationArray[i];
        var row = document.createElement('tr');
        var properties = ['lat', 'lng'];
  
        for(var j = 0; j &lt; properties.length; j++){
           var cell = document.createElement('td');
           cell.innerHTML = location[properties[j]];
           row.appendChild(cell);
         }
         table2.appendChild(row);
     }
  }
  &lt;/script&gt;
   &lt;body&gt;
     &lt;div id="container"&gt;
  
       &lt;div id="map"&gt;&lt;/div&gt;
  
       &lt;div id="info"&gt;
         &lt;p&gt;Her skal det så informasjon om cellen.&lt;/p&gt;
       &lt;/div&gt;
    &lt;/div&gt;  
  
  &lt;script&gt;
  displayDatabase();
  displayLocations();
  &lt;/script&gt;
  &lt;script&gt;
  
      var map;
      var bts = databaseArray[0];
      var loc = locationArray[0];
      var id1 = bts.id;
      var arfcn1 = bts.arfcn;
      var bsic1 = bts.bsic;
      var latitude = loc.lat;
      var longditude = loc.lng;
  
      window.initMap = function() {
  
        var MS = {lat: latitude, lng: longditude};
        var radius = 500;
        if(TA != 0){
            radius = radius * (TA+1);
        }
  
          var BTS1 = {lat: 60.78064, lng: 10.67037};
          var BTS2 = {lat: 60.76978, lng: 10.66677};
          var BTS3 = {lat: 60.76991, lng: 10.69672};
          var BTS4 = {lat: 60.78889, lng: 10.68462};
          var BTS5 = {lat: 60.76086, lng: 10.65141};
          var BTS8 = {lat: 60.79652, lng: 10.66857};
  
  
          var mapOptions = {
              zoom: 13,
              center: BTS1
          }
          map = new google.maps.Map(document.getElementById('map'), mapOptions);
  
          var image = 'tower1.png';
          var spyware = 'spyware.png';
  
        var circle = new google.maps.Circle({
            strokeColor: '#FF0000',
            strokeOpacity: 0.8,
            strokeWeight: 2,
            fillColor: '#FF0000'
            fillOpacity: 0.35,
            map: map,
            center: MS,
            radius: radius
          });
  
          var marker1 = new google.maps.Marker({
              position: BTS1,
              map: map,
              title: 'BTS: 1',
              icon: image
          });
  
          var marker2 = new google.maps.Marker({
              position: BTS2,
              map: map,
              title: 'BTS: 2',
              icon: image
          });
  
          var marker3 = new google.maps.Marker({
              position: BTS3,
              map: map,
              title: 'BTS: 3',
              icon: image
          });
  
          var marker4 = new google.maps.Marker({
              position: BTS4,
              map: map,
              title: 'BTS: 4',
              icon: image
          });
  
          var marker5 = new google.maps.Marker({
              position: BTS5,
              map: map,
              title: 'BTS: 5',
              icon: image
          });
  
  
  
          var infowindow1 = new google.maps.InfoWindow({
                content: "&lt;B&gt;BTS: 1 &lt;br&gt; ARFCN: 70 &lt;br&gt; BSIC: 29&lt;/B&gt; " //BCC 5
            });
          var infowindow2 = new google.maps.InfoWindow({
                content: "&lt;B&gt;BTS: 2 &lt;br&gt; ARFCN: 60 &lt;br&gt; BSIC: 28&lt;/B&gt; " //BCC 4
            });
          var infowindow3 = new google.maps.InfoWindow({
                content: "&lt;B&gt;BTS: 3 &lt;br&gt; ARFCN: 65 &lt;br&gt; BSIC: 27&lt;/B&gt; " //BCC 3
            });
          var infowindow4 = new google.maps.InfoWindow({
                content: "&lt;B&gt;BTS: 4 &lt;br&gt; ARFCN: 55 &lt;br&gt; BSIC: 26&lt;/B&gt; " //BCC 2
            });
  
          var infowindow5 = new google.maps.InfoWindow({
                content: "&lt;B&gt;BTS: 5 &lt;br&gt; ARFCN: 75 &lt;br&gt; BSIC: 29&lt;/B&gt; " //BCC 3
            });
  
             //=====Eventlistener for InfoWindow
            google.maps.event.addListener(marker1, 'click', function() {
              infowindow1.open(map,marker1);
            });
  
            google.maps.event.addListener(marker2, 'click', function() {
                  infowindow2.open(map,marker2);
                });
  
            google.maps.event.addListener(marker3, 'click', function() {
                  infowindow3.open(map,marker3);
                });
  
            google.maps.event.addListener(marker4, 'click', function() {
                  infowindow4.open(map,marker4);
                });
  
            google.maps.event.addListener(marker5, 'click', function() {
                  infowindow5.open(map,marker5);
                });             
  
      }
  
      &lt;/script&gt;
      &lt;script src="https://maps.googleapis.com/maps/api/js?key=API-key&amp;callback=initMap"
    async defer&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank you!</p>