JSFiddle - React, Tailwind, and code Playground
HTML
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map_canvas"></div>
CSS
html, body, #map_canvas { margin: 0; padding: 0; height: 100% }
JavaScript
var locations = ["Los Angeles", "Davis", "Truth or Consequences", "Ann Arbor", "Massachusetts"];
var infowindow = null;
var geocoder;
$(document).ready(function () { initialize(); });
function codeAddress(address, callback) {
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
callback(results[0].geometry.location);
}
});
}
function initialize() {
codeAddress("Chicago, IL", function(default_location) {
var map = new google.maps.Map(document.getElementById("map_canvas"),
{ center: default_location,
zoom: 3, mapTypeId: google.maps.MapTypeId.ROADMAP });
for (var i = 0; i < locations.length; i++) {
codeAddress(locations[i], function(latLng) {
new google.maps.Marker({map:map, position:latLng});
});
}
});
}