/* Second corner of the polygon will have latitude of  the second point and longitude of the first point */ var secondCorner = new  google.maps.LatLng(currentPoint.lat(), _this.selectionPoints[0].lng()); /* We need to add all newly created points to the array  so we can create the polygon out of them */ _this.selectionPoints.push(firstCorner, currentPoint,  secondCorner); /* Traverse all points and for each, create a marker &  place it to the polygon */ for (var i = 0; i < _this.selectionPoints.length; i++)  { _this.polyLine.getPath().push(_this.selectionPoints[i]); /* Marker for the first point has already been  created, skip it */ if (i > 0) { var marker = new google.maps.Marker({position:  _this.selectionPoints[i], map: _this.map}); _this.selectionPathMarkers.push(marker); } } } /* And now, close the loop (so it makes the square) */ _this.polygon = new google.maps.Polygon({ paths: _this.polyLine.getPath(), map: _this.map, strokeColor: "#FF0000", strokeOpacity: 0.8, strokeWeight: 2, fillColor: "#00649D", fillOpacity: 0.35 }); }); }, /* This method takes care of reloading all data when necessary */ reload: function() { this.getCurrentData(); }, getCurrentData: function() { var _this = this; this.fetchData().then(function(data) { 562  IBM Watson Content Analytics: Discovering Actionable Insight from Your Content