Google Maps With States Overlay

built from LyleScott/google-maps-us-states-polygons

by merganser

HTML

<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=initMap" async defer></script>

CSS

/* Always set the map height explicitly to define the size of the div
 * element that contains the map. */
#map {
  height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

JavaScript

var map;
var stateCoords = [['Alaska',
  [[70.0187, -141.0205],
   [70.1292, -141.7291],
   [70.4515, -144.8163],
   [70.7471, -148.4583],
   [70.7923, -151.1609],
   [71.147, -152.6221],
   [71.1185, -153.9954],
   [71.4307, -154.8853],
   [71.5232, -156.7529],
   [71.2796, -157.9449],
   [71.2249, -159.6313],
   [70.6363, -161.8671],
   [70.0843, -163.5809],
   [69.3028, -165.2399],
   [69.1782, -166.8768],
   [68.3344, -168.0414],
   [67.6844, -165.9155],
   [67.2933, -164.6082],
   [66.7789, -164.0149],
   [66.581, -165.7507],
   [66.2867, -167.5745],
   [66.0269, -168.9862],
   [65.497, -168.9478],
   [65.042, -167.4756],
   [64.3922, -167.0142],
   [64.0554, -165.7343],
   [64.0193, -163.2294],
   [63.9615, -162.1143],
   [63.6877, -163.6029],
   [63.453, -165.3717],
   [62.4133, -166.3715],
   [61.6534, -166.9867],
   [60.8556, -166.4429],
   [60.5357, -167.8381],
   [59.5482, -167.7118],
   [59.4115, -165.8002],
   [59.3696, -164.5972],
   [59.1168, -162.8558],
   [58.1185, -162.5427],
   [58.1359, -160.6421],
   [58.0285, -159.505],
   [57.6336, -158.8953],
   [56.909, -159.906],
   [56.3926, -160.6531],
   [56.2342, -161.8835],
   [55.724, -162.9822],
   [55.2478, -164.3994],
   [54.7753, -165.3168],
   [54.1463, -167.1075],
   [53.5632, -168.5852],
   [53.1402, -169.9146],
   [52.5964, -169.5959],
   [52.9089, -168.2227],
   [54.2139, -162.7734],
   [54.6786, -159.1452],
   [55.6567, -155.4634],
   [57.351, -152.14],
   [59.2209, -150.8203],
   [59.7695, -147.4461],
   [60.3521, -145.985],
   [59.8917, -144.1544],
   [59.8172, -141.6811],
   [59.5225, -140.5124],
   [59.0292, -138.8548],
   [57.9032, -136.8526],
   [56.9157, -136.0725],
   [56.1555, -134.9794],
   [55.3237, -134.0057],
   [54.6341, -133.6418],
   [54.7135, -130.6261],
   [55.2869, -129.993],
   [55.9869, -130.0108],
   [56.1057, -130.1083],
   [56.6086, -131.5887],
   [57.8404, -132.8755],
   [58.7276, -133.8423],
   [59.3108, -134.9121],
   [59.802, -135.4724],
   [59.6039,...