diff --git a/lib/components/map/base-map.js b/lib/components/map/base-map.js index bb40defad..b0ace488f 100644 --- a/lib/components/map/base-map.js +++ b/lib/components/map/base-map.js @@ -275,6 +275,7 @@ class BaseMap extends Component { center={center} // onClick={this._onLeftClick} zoom={config.map.initZoom || 13} + maxZoom={config.map.maxZoom} onOverlayAdd={this._onOverlayAdd} onOverlayRemove={this._onOverlayRemove} onViewportChanged={this._onViewportChanged} diff --git a/lib/util/itinerary.js b/lib/util/itinerary.js index c89e1bcac..8caa6d853 100644 --- a/lib/util/itinerary.js +++ b/lib/util/itinerary.js @@ -228,11 +228,24 @@ export function getItineraryBounds (itinerary) { return latLngBounds(coords) } +/** + * Return a leaflet LatLngBounds object that encloses the given leg's geometry. + */ export function getLegBounds (leg) { - return latLngBounds(polyline + let coords = polyline .toGeoJSON(leg.legGeometry.points) .coordinates.map(c => [c[1], c[0]]) - ) + + // in certain cases, there might be zero-length coordinates in the leg + // geometry. In these cases, build us an array of coordinates using the from + // and to data of the leg. + if (coords.length === 0) { + coords = [ + [leg.from.lat, leg.from.lon], + [leg.to.lat, leg.to.lon] + ] + } + return latLngBounds(coords) } export function routeComparator (a, b) {