title: Google API V3: How to remove overlay using Custom Overlay's onRemove() method
body: <p>I need help on how to properly use <code>onRemove()</code> method of Google Maps API v3's Custom Overlay. I have a marker on Google Map that, when clicked, will display a d3 doughnut chart that will display certain text on hover. The chart is displayed on top of Custom Overlay. The chart should be remove (ie remove the overlay) when the marker is clicked again. </p>
  
  <p>Here is my <a href="https://jsfiddle.net/hk73whr5/4/" rel="nofollow">JSFiddle</a>.</p>
  
  <p>The remove overlay function somehow works but it still returns the error "TypeError: this.remove is not a function" which after some googling resulted from the absence of <code>onRemove()</code> method. </p>
  
  <p>So I've tried adding <code>onRemove</code> method:</p>
  
  <pre><code>overlay.onRemove = function(){
      d3.selectAll(".donut").remove();
  }
  </code></pre>
  
  <p>which didn't work. I also tried:</p>
  
  <pre><code>overlay.onRemove = function(){
      layer.parentNode.removeChild(layer);
  }
  </code></pre>
  
  <p>and this also didn't work. </p>
  
  <p>So my question is, how exactly do I use the <code>onRemove()</code> method? Or should I ignore the <em>TypeError</em> error?</p>