JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp.&amp;sensor=false&amp;.js"></script>
<div id="map_canvas"></div>

CSS

html, body, #map_canvas {
    margin:0;
    height:100%;
}

JavaScript

//keep a reference to the original setPosition-function
var fx = google.maps.InfoWindow.prototype.setPosition;

//override the built-in setPosition-method
google.maps.InfoWindow.prototype.setPosition = function () {
  
  //this property isn't documented, but as it seems
  //it's only defined for InfoWindows opened on POI's
  if (this.logAsInternal) {
    google.maps.event.addListenerOnce(this, 'map_changed',function () {
      var map = this.getMap();
      //the infoWindow will be opened, usually after a click on a POI
      if (map) {
        //trigger the click
        google.maps.event.trigger(map, 'click', {latLng: this.getPosition()});
        alert('POI-click intercepted');
        //hide the default-infoWindow of the POI
        this.setMap(null);
      }
    });
  }
    //call the original setPosition-method
  fx.apply(this, arguments);
};
      

      function initialize() {
          var mapOptions = {
              zoom: 14,
              center: new google.maps.LatLng(51.508742,-0.120850),
              mapTypeId: google.maps.MapTypeId.ROADMAP
          };
          map = new google.maps.Map(document.getElementById('map_canvas'),
          mapOptions);


          
          google.maps.event.addListener(map,'click',function(e){
              placeMarker(e.latLng)
          })
      }


      function placeMarker(location) {
    var marker = new google.maps.Marker({
        position: location,
        map: map,
    });
    var infowindow = new google.maps.InfoWindow({
        content: 'Latitude: ' + location.lat() + ' Longitude: ' + location.lng() 
    });
    infowindow.open(map,marker);
}
      google.maps.event.addDomListener(window, 'load', initialize);