Rectangles
by BuddhiP
HTML
<!DOCTYPE html>
<html>
<head>
<title>Rectangles</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<!-- jsFiddle will insert css and js -->
</head>
<body>
<div id="map"></div>
<!-- Async script executes immediately and must be after any DOM elements used in callback. -->
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIwzALxUPNbatRBj3Xi1Uhp0fFzwWNBkE&callback=initMap&libraries=&v=weekly"
async
></script>
</body>
</html>
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
// This example adds a red rectangle to a map.
function initMap() {
const map = new google.maps.Map(document.getElementById("map"), {
zoom: 11,
center: new google.maps.LatLng(42.46819487494597, -71.67416171676783),
mapTypeId: "terrain",
});
const polygon = new google.maps.Polygon({
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.05,
map,
paths: [
new google.maps.LatLng(42.46819487494597, -71.67416171676783),
new google.maps.LatLng(42.461483315970845, -71.65811137802271),
new google.maps.LatLng(42.45800061977398, -71.65094451553492),
new google.maps.LatLng(42.453251176423954, -71.64515094406275),
new google.maps.LatLng(42.45135129822927, -71.62575320846705),
new google.maps.LatLng(42.44438458512172, -71.58730106002955),
new google.maps.LatLng(42.42951439494652, -71.59412459976343),
new google.maps.LatLng(42.41641493664916, -71.605754658052),
new google.maps.LatLng(42.41517929631783, -71.68772296554712),
],
editable: false,
zoom: true,
});
}