JSFiddle - React, Tailwind, and code Playground
HTML
<div id="map-canvas"></div>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
CSS
html, body {
height: 100%;
margin: 0;
padding: 0;
}
p,h4 {
margin:0;
}
#map-canvas{
width:425px;
height:300px;
margin:1em;
}
JavaScript
function initialize() {
var myLatlng = new google.maps.LatLng(-38.06794990,145.30192430);
var mapOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var contentString = '<div style="width:300px;"><H4>Heading</H4><P><B>Address:</B> Community Centre 51L The Strand, Narre Warren South 3805</P></div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Food Waste and Organics workshop'
});
infowindow.open(map, marker);
google.maps.event.addListener(marker, 'click', function(event) {
infowindow.open(map, marker);
});
google.maps.event.addListenerOnce(map, 'idle', function(){
//google.maps.event.trigger(marker,'click');
});
}
google.maps.event.addDomListener(window, 'load', initialize);