title: Is there a way to test the presence of a Google Map overlay?
body: <p>I'm creating heatmap overlays on a google map, and I need to clear the old data before overlaying the new data. In order to do this I'm using the following code:</p>
  
  <pre><code>heatmap.setMap(null)
  heatmap.setMap(map)
  </code></pre>
  
  <p>This works if the heatmap has been set, but it will not work if it's the first time the user creates an overlay. I was wondering if there is a way to test the presence of an overlay. This code has not been working, but I'm thinking along the lines of:</p>
  
  <pre><code>if(heatmap.setMap(map) == true){
      heatmap.setMap(null)
  } else {
      ...
  }
  </code></pre>
  
  <p>The most important thing is testing the presence of an overlay. Does anybody know if there is something I could place in the if condition that would tell me if that overlay already exists?</p>
  
  <p>Please let me know. Thanks. </p>