diff --git a/src/controls/inputs.js b/src/controls/inputs.js index 3499590..d5ee0d2 100644 --- a/src/controls/inputs.js +++ b/src/controls/inputs.js @@ -36,15 +36,18 @@ export default class Inputs { } animateToCoordinates(mode, coords) { - const { origin, destination, routePadding } = this.store.getState(); - + const { origin, destination, waypoints, routePadding } = this.store.getState(); + if (origin.geometry && destination.geometry && !isEqual(origin.geometry, destination.geometry)) { + + const ways = waypoints.filter((waypoint) => (waypoint.geometry)) + // Animate map to fit bounds. const bb = extent({ type: 'FeatureCollection', - features: [origin, destination] + features: [origin, destination, ...ways] }); this._map.fitBounds([[bb[0], bb[1]], [bb[2], bb[3]]], {padding: routePadding}); diff --git a/src/directions.js b/src/directions.js index bc21f57..89937ec 100644 --- a/src/directions.js +++ b/src/directions.js @@ -300,7 +300,6 @@ export default class MapboxDirections { } } else { this.actions.setDestinationFromCoordinates(coords); - this._map.flyTo({ center: coords }); } } }