@@ -11,6 +11,7 @@ import LocationIcon from '../icons/location-icon'
11
11
import { constructLocation } from '../../util/map'
12
12
import { getActiveItinerary , getActiveSearch } from '../../util/state'
13
13
import { getItineraryBounds , getLegBounds , legLocationAtDistance } from '../../util/itinerary'
14
+ import { isMobile } from '../../util/ui'
14
15
15
16
import L from 'leaflet'
16
17
@@ -127,10 +128,21 @@ class BaseMap extends Component {
127
128
128
129
// If no itinerary update but from/to locations are present, fit to those
129
130
} 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
+ }
134
146
135
147
// If only from or to is set, pan to that
136
148
} else if ( newProps . query . from && fromChanged ) {
0 commit comments