Delete Portion of a line

Home Forums MapPress Support Delete Portion of a line

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #14113
    ToreyAzure
    Participant

    I have drawn a fairly complex and long line for a trail in a map. I need to change a portion of that line now. Is there a way to delete nodes in the line?

    #14114
    ToreyAzure
    Participant

    Also, anyway to continue drawing a line once you’ve saved it? Snapping and continuing to draw on the same shape, rather than creating a new shape when I restart?

    #14115
    Chris
    Keymaster

    Hi,

    The plugin enables Google’s ‘drawing manager’, which takes care of the line/shape editing. It’s not at all intuitive, but I think it’s possible to do what you want:

    To delete a vertex: drag an existing vertex over another one and the first vertex is deleted

    To insert a vertex: drag any of the existing vertices. This will create two new vertices each time you drag.


    As a side-note: if you’re going to be drawing complex shapes, it might be easier to do it in Google Maps or Google Earth and then embed them in the MapPress map as a KML file. Google’s own applications have better line/shape editing tools that are not available in the maps API.

    #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.)

    #14311
    ToreyAzure
    Participant
    #14312
    Chris
    Keymaster

    I think the procedure I described for adding vertices does work, but you’re right about deletion – even if the vertices are placed on top of each other they both still exist.

    I’ve updated the plugin to allow deleting vertices with a right-click. Please send me an email using the contact form if you’d like a copy to test.

    #14313
    ToreyAzure
    Participant

    Cool, I’ll email you.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.