title: Google maps Multiple marker: setMap: not an instance of Map; and not an instance of StreetViewPanorama
body: <p>I want to display Near by schools of my selected property in google maps API with marker, but it is showing me error, setMap: not an instance of Map; and not an instance of StreetViewPanorama.</p>
  <p>Below is my code, please help me to find where is my mistake.</p>
  <pre><code>
      &lt;script type=&quot;text/javascript&quot;&gt;
          function initMap() {
              var lat = $('#lat').val();
              var lng = $('#lng').val();
              var address = $('#address').val();
              var latNumber = Number(lat);
              var lngNumber = Number(lng);
              const myLatLng = {
                  lat: latNumber,
                  lng: lngNumber
              };
              const map = new google.maps.Map(document.getElementById(&quot;map&quot;), {
                  zoom: 17,
                  center: myLatLng,
              });
              new google.maps.Marker({
                      position: myLatLng,
                      map,
                      title: address,
                  });
      
              infowindow = new google.maps.InfoWindow();
              var service = new google.maps.places.PlacesService(map);
              service.nearbySearch({
                      location: myLatLng,
                      radius: 500,
                      type: ['school']
                  },
                  callback);
          }
      
          function callback(results, status) {
              if (status === google.maps.places.PlacesServiceStatus.OK) {
                  for (var i = 0; i &lt; results.length; i++) {
                      createMarker(results[i]);
                  }
              }
          }
      
          function createMarker(place) {
              var latNumber=place.geometry.location.lat();
              var lngNumber=place.geometry.location.lng();
      
              let schools = { lat: latNumber, lng: lngNumber };
              // var placeLoc = place.geometry.location;
              new google.maps.Marker({
                  position: schools,
                  map,
                 title: 'school'
              });
              google.maps.event.addListener(marker, 'click', function() {
                  infowindow.setContent(place.name);
                  infowindow.open(map, this);
              });
          }
      
          window.initMap = initMap;
      &lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot;
          src=&quot;https://maps.google.com/maps/api/js?key='APIKEY'&amp;sensor=true&amp;libraries=geometry&amp;libraries=places&amp;callback=initMap&quot;&gt;
      &lt;/script&gt;
  
  </code></pre>