Google Map How to clear poligon and marker

I can not speak English well. Google Map How to clear poligon and marker? Help me please. I want poligon and market to be deleted when I click the button. I tried but I couldn’t.
Myscript :

function initMap() {

....
    function attachPolygonInfoWindow(polygon) {
        .....
    }
    google.maps.event.addListener(drawingManager, "overlaycomplete", function(e) {
        $(".clear").removeClass("d-none");
        if (e.type == "polygon") {
            drawingManager.setOptions({
                drawingControl: false,
            });
            allOverlays.push(e);
            if (e.type != google.maps.drawing.OverlayType.MARKER) {
                drawingManager.setDrawingMode(null);
                var newShape = e.overlay;
                newShape.type = e.type;
                google.maps.event.addListener(newShape, "click", function() {
                    setSelection(newShape);
                });
                    var path = newShape.getPath();
                    google.maps.event.addListener(path, "insert_at", function() {
                        attachPolygonInfoWindow(newShape);
                    });
                    google.maps.event.addListener(path, "set_at", function() {
                        attachPolygonInfoWindow(newShape);
                        var data = "";
                        $.each(e.overlay.getPath().getArray(), function(key, latlng) {
                            var lat = latlng.lat();
                            var lon = latlng.lng();
                            data += lat + " - " + lon + "<br>";
                        });
                        $(".map_coordinat").html(map.getCenter().lat() + " - " + map.getCenter().lng());
                        $(".poligon_coordinat").html(data);
                    });
                    attachPolygonInfoWindow(newShape);
                }
                setSelection(newShape);
            }
        
    });
}