I'm struggling with Google Maps Api V3 Polylines. It is possible with this API to create user-editable shapes, as this tutorial shows for the Rectangle shape. But when I do the same with a Polyline, I have a problem with the center of the segment.
In the Rectangle example, such a center point is used to extend the size of the rectangle's side. But in my Polyline, this point, when dragged, breaks the line onto two new lines. Thus, each of them gets a new center. As a consequence, instead of 2 points, I now have 5 points. And this is endless : everytime I click on a center point and I drag it, it creates new points.
Here is a part of my code :
var polyCoord = [
new google.maps.LatLng(41.86, 8.73),
new google.maps.LatLng(41.88, 8.75)
];
// Polyline
var pol = new google.maps.Polyline({
path: polyCoord,
editable: true
});
pol.setMap(map);
How can I make editable Polylines with only 2 points ? Thanks
Using the concept from this question: Avoiding vertex drag maps api v3
Don't use editable polylines (those have the edit handle in the middle that you don't want).
Bind a marker to each of the two vertices of the polyline, make those draggable.
proof of concept fiddle
code snippet: