JSFiddle - React, Tailwind, and code Playground

by iamjpg

HTML

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

</div>

CSS

#map {
  width: 600px;
  height: 600px;
}

JavaScript

var citymap = {
  chicago: {
    loc: "Chicago, IL",
    shootings: 140000

  },
  newyork: {
    loc: "New York, NY",
    shootings: 80000
  },
  losangeles: {
    loc: "Los Angeles, CA",
    shootings: 40000
  },

};
var map;

var geocoder = new google.maps.Geocoder();

var geocodeThis = function(obj) {
  geocoder.geocode({
    'address': obj.loc
  }, function(results, status) {
    center = {
      lat: results[0].geometry.location.lat(),
      lng: results[0].geometry.location.lng()
    }

    // Add the circle for this city to the map.
    var cityCircle = new google.maps.Circle({
      strokeColor: '#FF0000',
      strokeOpacity: 0.8,
      strokeWeight: 2,
      fillColor: '#FF0000',
      fillOpacity: 0.5,
      map: map,
      center: center,
      radius: obj.shootings
    });

  });
}

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {
      lat: 39.14,
      lng: -98.1
    },
    zoom: 4
  });

  for (var key in citymap) {
    if (citymap.hasOwnProperty(key)) {
      var obj = citymap[key];
      geocodeThis(obj);
    }
  }


}

initMap();