JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp.&sensor=false&.js"></script>
<div id="map_canvas"></div>
CSS
html, body, #map_canvas {
margin:0;
height:100%;
}
JavaScript
function initialize() {
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(52.5498783, 13.425209099999961),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
//run this after loading the maps-api
(function(){
var fx = google.maps.InfoWindow.prototype.setContent;
//override the built-in setContent-method
google.maps.InfoWindow.prototype.setContent = 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(),that=this;
//attach the click-handler when the infowindow opens
if (map) {
google.maps.event.addListenerOnce(map, 'click', function(){that.close();});
}
});
}
//call the original setPosition-method
fx.apply(this, arguments);
};})();
google.maps.event.addDomListener(window, 'load', initialize);