Google Maps setMap(null) does not work

I try to delete markers on the map by using setMap(null) but it does not work. Do you have any idea or solution for this?

Here my delete method:

deleteMarkers(marketler){


  for (var i = 0; i < gmarkers.length; i++) 
      {

         gmarkers[i].setMap(null);

      }
      
  }

Could you provide some information on what library you are using to include Google Maps in your app? There are lots, so without that information we just had to guess…