Home › Forums › MapPress Support › Delete Portion of a line
- This topic has 6 replies, 2 voices, and was last updated 8 years, 11 months ago by
ToreyAzure.
-
AuthorPosts
-
January 21, 2014 at 8:00 am #14113
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?
January 21, 2014 at 8:10 am #14114Also, 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?
January 21, 2014 at 9:37 am #14115Hi,
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.February 24, 2014 at 7:51 am #14310From what I can tell this doesn’t work. But I did find a solution on known issues with Google Drawing editor.
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 assumes
my_poly
is an normal google.maps.Polygon or Polylinevar 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.)
February 24, 2014 at 7:57 am #14311And on Stack Overflow
http://stackoverflow.com/questions/8831382/google-maps-v3-delete-vertex-on-polygon
February 24, 2014 at 9:25 am #14312I 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.
February 24, 2014 at 2:00 pm #14313Cool, I’ll email you.
-
AuthorPosts
- You must be logged in to reply to this topic.