I have an agm-polyline with 2 agm-polyline-points. When moving the edge of the line (the middle point) I want the save the new line with 3 points. The problem is, when moving the edge to a new location, the event returns the wrong coordinates / or just coordinates of something else.
<agm-map [zoom]="zoom" [latitude]="lat" [longitude]="lng" style="height: 500px">
<agm-polyline [editable]="true" (lineMouseUp)="addEdge($event)">
<agm-polyline-point
*ngFor="let point of points" [latitude]="point.lat" [longitude]="point.lng"></agm-polyline-point>
</agm-polyline>
</agm-map>
lat: number = 32.0795723;
lng: number = 34.7757089;
zoom: number = 16;
@ViewChild('line') polyLine : AgmPolyline;
points = [
{lat: 32.0795723, lng: 34.7757089},
{lat: 32.0780565, lng: 34.7798036}
]
addEdge(event){
let point = {lat: event.latLng.lat(), lng: event.latLng.lng()};
if (event.vertex !== undefined) {
this.points[event.vertex] = point;
} else if (event.edge !== undefined) {
this.points.splice(event.edge + 1, 0, point);
}
console.log(this.points)
}
take a look at the stackblitz.