Reply To: Delete Portion of a line

Home Forums MapPress Support Delete Portion of a line Reply To: Delete Portion of a line

#14310
ToreyAzure
Participant

From what I can tell this doesn’t work. But I did find a solution on known issues with Google Drawing editor.

link here: https://code.google.com/p/gmaps-api-issues/issues/detail?id=3760&q=apitype%3AJavascript3&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars

In there I found a solution below. But I don’t know where to put the code. Any advice.

Copy and paste below *****************

Google Maps now provides a “PolyMouseEvent” callback object on events that are triggered from a Polygon or Polyline.

To build on the other answers which suggested a solution involving a right click, all you would need to do is the following in the latest versions of the V3 API:

// this assumesmy_poly is an normal google.maps.Polygon or Polyline

    var deleteNode = function(mev) {
      if (mev.vertex != null) {
        my_poly.getPath().removeAt(mev.vertex);
      }
    }
    google.maps.event.addListener(my_poly, 'rightclick', deleteNode);

You’ll notice that any complex calculations on whether or not we are near the point are no longer necesary, as the Google Maps API is now telling us which vertex we’ve clicked on.

Note: this will only work while the Polyline/Polygon is in edit mode. (Which is when the vertices you might want to delete are visible.)