forwards and backwards drawing

This commit is contained in:
Fedor Katurov 2020-01-22 15:16:34 +07:00
parent bbd7d6a89a
commit ad676d5fde
11 changed files with 119 additions and 21 deletions

View file

@ -45,9 +45,7 @@ class InteractivePoly extends Polyline {
this.startDragHinting();
}
setLatLngs = (latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][]) => {
super.setLatLngs(latlngs);
updateConstraintsToLatLngs = (latlngs: LatLngExpression[]) => {
if (this.is_drawing) {
// update mouse hinter on latlngs change
const constraints = this.constrLine.getLatLngs() as LatLng[];
@ -63,6 +61,12 @@ class InteractivePoly extends Polyline {
this.setConstraints([constraints[0], source as LatLng]);
}
}
setLatLngs = (latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][]) => {
super.setLatLngs(latlngs);
this.updateConstraintsToLatLngs(latlngs as LatLngExpression[]);
return this;
};
@ -492,6 +496,11 @@ class InteractivePoly extends Polyline {
this.constrLine.setLatLngs(coords);
};
setDirection = (direction: 'forward' | 'backward') => {
this.drawing_direction = direction;
this.updateConstraintsToLatLngs(this.getLatLngs() as LatLngExpression[]);
}
dropMarker = ({ target }: LeafletMouseEvent): void => {
const index = this.markers.indexOf(target);
const latlngs = this.getLatLngs();