Remove Circle / Polygons from Google Map api v3

What differentiates circle/rectangle from a polygon in Google maps is that circle/rectangles are interpreted as closed figures bounded by bounds where as for a polygon you can define a path with number of points on it to draw. Although they both can be removed by setting map as null, Polygons still offer more options. If whole figure is to be removed, call setMap with null. But if only parts of polygon has to be removed, iterate over them and remove them using removeAt. Following example shows
** closedFig is the object of class google.maps.Circle or google.maps.Rectangle or 
** google.maps.Polygon
removeFig(closedFig) {

** poly is the object of class google.maps.Polygon
** vertices is the collection of vertices to be removed. 
** if vertices empty this removes the whole polygon
removeSelected(poly, vertices) {
       if (vertices.length == 0 )
		vertices = poly.getPath();

	// Iterate over the vertices.
	for (var i = vertices.length-1; i > -1; i--) {