You need to make a map with the ability to add polygons by clicking on it. Also, when clicking on a polygon, it should be highlighted, and when you click on the delete button, it should be deleted. It turned out something like this
addMarker: function (latLng, map) { var o = this.options; this.latLng = latLng; var newMarker = new google.maps.Marker({ position: this.latLng, map: map, icon: { path: google.maps.SymbolPath.CIRCLE, scale: 3, strokeColor: '#FF0000', strokeOpacity: 0.2 } }); o.markers.push(newMarker); var vertexLat = +latLng.lat(); var vertexLng = +latLng.lng(); var vertex = {lat: vertexLat, lng: vertexLng}; o.figureCoords.push(vertex); }, constructPolygon: function () { var o = this.options; this.newFigure = new google.maps.Polygon({ paths: o.figureCoords, strokeColor: '#FF0000', strokeOpacity: 0.5, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.1, editable: true, draggable: true }); } We click on the map, we create vertices, when we click on the "Add" button, a polygon is drawn using the coordinates saved in the array. There may be a lot of them on the map. Delete everything turns out, but you need to make it so that by clicking on a specific polygon, it is highlighted and it is possible to remove it by clicking on the "delete" button