router now properly handles poly changes

This commit is contained in:
Fedor Katurov 2018-08-16 15:39:54 +07:00
parent e477f50283
commit 245b559e2d
3 changed files with 40 additions and 4 deletions

View file

@ -95,6 +95,32 @@ export class Router {
};
startFrom = latlngs => {
const waypoints = this.router.getWaypoints();
if (waypoints && waypoints.length) {
waypoints[0] = { ...latlngs };
this.router.setWaypoints(waypoints);
return;
}
this.router.setWaypoints([{ ...latlngs }]);
}
};
moveStart = latlng => {
const waypoints = this.router.getWaypoints();
const { latLng } = (waypoints[0] || {});
if (!latLng || !latlng) return;
if (
latlng.lat.toFixed(5) === latLng.lat.toFixed(5) &&
latlng.lng.toFixed(5) === latLng.lng.toFixed(5)
) {
return;
}
waypoints[0] = { ...latlng };
this.router.setWaypoints(waypoints);
};
}