Skip to content

Commit

Permalink
Merge pull request #135 from opentripplanner/dev
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
landonreed authored Feb 20, 2020
2 parents 7c175ee + 8cb9683 commit 21348d3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/components/map/base-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import LocationIcon from '../icons/location-icon'
import { constructLocation } from '../../util/map'
import { getActiveItinerary, getActiveSearch } from '../../util/state'
import { getItineraryBounds, getLegBounds, legLocationAtDistance } from '../../util/itinerary'
import { isMobile } from '../../util/ui'

import L from 'leaflet'

Expand Down Expand Up @@ -127,10 +128,21 @@ class BaseMap extends Component {

// If no itinerary update but from/to locations are present, fit to those
} else if (newProps.query.from && newProps.query.to && (fromChanged || toChanged)) {
map.leafletElement.fitBounds([
[newProps.query.from.lat, newProps.query.from.lon],
[newProps.query.to.lat, newProps.query.to.lon]
], { padding })
// On certain mobile devices (e.g., Android + Chrome), setting from and to
// locations via the location search component causes issues for this
// fitBounds invocation. The map does not appear to be visible when these
// prop changes are detected, so for now we should perhaps just skip this
// fitBounds on mobile.
// See https://github.com/opentripplanner/otp-react-redux/issues/133 for
// more info.
// TODO: Fix this so mobile devices will also update the bounds to the
// from/to locations.
if (!isMobile()) {
map.leafletElement.fitBounds([
[newProps.query.from.lat, newProps.query.from.lon],
[newProps.query.to.lat, newProps.query.to.lon]
], { padding })
}

// If only from or to is set, pan to that
} else if (newProps.query.from && fromChanged) {
Expand Down

0 comments on commit 21348d3

Please sign in to comment.