Skip to content

Commit 21348d3

Browse files
authored
Merge pull request #135 from opentripplanner/dev
New release
2 parents 7c175ee + 8cb9683 commit 21348d3

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Diff for: lib/components/map/base-map.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import LocationIcon from '../icons/location-icon'
1111
import { constructLocation } from '../../util/map'
1212
import { getActiveItinerary, getActiveSearch } from '../../util/state'
1313
import { getItineraryBounds, getLegBounds, legLocationAtDistance } from '../../util/itinerary'
14+
import { isMobile } from '../../util/ui'
1415

1516
import L from 'leaflet'
1617

@@ -127,10 +128,21 @@ class BaseMap extends Component {
127128

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

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

0 commit comments

Comments
 (0)