title: Delete a vertex of polygon google maps API v3
body: <p>So there are many posts on how to delete the vertex of a google maps polygon.  None of them have worked for me - this may be due to the outdated API's they reference.  I am trying to limit the number of points a user can create on a polygon.  If they create more than a certain number of points I would like to either programmatically trigger the 'undo' functionality built into google maps or have some way of deleting the last vertex created.  </p>
  
  <p>When I create the initial polygon for a user to work with I add this event listener in:</p>
  
  <pre><code>google.maps.event.addListener(myPolygon.getPath(), 'insert_at', function(event){
    var numPoints = myPolygon.getPath().length;
  
    if(numPoints == 5){
      myPolygon.getPath().removeAt(4);
    }
  });
  </code></pre>
  
  <p>This ends up removing a point from the polygon (NOT necessarily the last point created).  Sometimes it causes the following error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'b' of undefined.</p>
  </blockquote>
  
  <p>I have attempted using a 'click' listener on the polygon, but the click event does not fire when a user creates a new vertex.  It only fires when the actual polygon shaped is clicked.</p>