From 273d7ff2e4270ad5f0c5490412db6cbfeb4d88c9 Mon Sep 17 00:00:00 2001 From: Patrick Kaminski Date: Tue, 23 Oct 2018 22:02:01 -0300 Subject: [PATCH] fitBounds to all points (origin, destination and waypoints) ref 116 --- src/controls/inputs.js | 6 ++++-- src/directions.js | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controls/inputs.js b/src/controls/inputs.js index 7b235dc..4b39b9c 100644 --- a/src/controls/inputs.js +++ b/src/controls/inputs.js @@ -36,16 +36,18 @@ export default class Inputs { } animateToCoordinates(mode, coords) { - const { origin, destination } = this.store.getState(); + const { origin, destination, waypoints } = 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: 80 }); diff --git a/src/directions.js b/src/directions.js index 819cd99..c2d0a88 100644 --- a/src/directions.js +++ b/src/directions.js @@ -293,7 +293,6 @@ export default class MapboxDirections { } } else { this.actions.setDestinationFromCoordinates(coords); - this._map.flyTo({ center: coords }); } } }