I\'m using the HeatmapLayer api https://developers.google.com/maps/documentation/javascript/layers#JSHeatMaps
I generate the heatmap like this:
heatm
Take a look at the documentation here google JSHeatMaps.
Check out this example. You can view the logic for the toggle button.
heatmap.setMap(null)