Skip to content

Commit bedc369

Browse files
committed
fitBounds to all points (origin, destination and waypoints)
ref 116
1 parent 8f99969 commit bedc369

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/controls/inputs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ export default class Inputs {
3636
}
3737

3838
animateToCoordinates(mode, coords) {
39-
const { origin, destination } = this.store.getState();
39+
const { origin, destination, waypoints } = this.store.getState();
4040

4141
if (origin.geometry &&
4242
destination.geometry &&
4343
!isEqual(origin.geometry, destination.geometry)) {
4444

45+
const ways = waypoints.filter((waypoint) => (waypoint.geometry))
46+
4547
// Animate map to fit bounds.
4648
const bb = extent({
4749
type: 'FeatureCollection',
48-
features: [origin, destination]
50+
features: [origin, destination, ...ways]
4951
});
5052

5153
this._map.fitBounds([[bb[0], bb[1]], [bb[2], bb[3]]], { padding: 80 });

src/directions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ export default class MapboxDirections {
293293
}
294294
} else {
295295
this.actions.setDestinationFromCoordinates(coords);
296-
this._map.flyTo({ center: coords });
297296
}
298297
}
299298
}

0 commit comments

Comments
 (0)