@@ -57,11 +57,12 @@ function StopPageMap(
57
57
const maxShowRouteDistance = breakpoint === 'large' ? 900 : 470 ;
58
58
const { environment } = useContext ( ReactRelayContext ) ;
59
59
const [ walk , setWalk ] = useState ( null ) ;
60
+ const [ bounds , setBounds ] = useState ( null ) ;
60
61
const isRouting = useRef ( false ) ;
61
62
62
63
useEffect ( ( ) => {
63
64
const fetchWalk = async targetStop => {
64
- if ( locationState . hasLocation && locationState . address ) {
65
+ if ( locationState . hasLocation ) {
65
66
if ( distance ( locationState , stop ) < maxShowRouteDistance ) {
66
67
const settings = getSettings ( config ) ;
67
68
const variables = {
@@ -98,7 +99,20 @@ function StopPageMap(
98
99
isRouting . current = true ;
99
100
fetchWalk ( stop ) ;
100
101
}
101
- } , [ locationState . status ] ) ;
102
+ if (
103
+ locationState . lat &&
104
+ locationState . lon &&
105
+ distance ( locationState , stop ) < maxShowRouteDistance
106
+ ) {
107
+ setBounds ( [
108
+ [ locationState . lat , locationState . lon ] ,
109
+ [
110
+ stop . lat + ( stop . lat - locationState . lat ) ,
111
+ stop . lon + ( stop . lon - locationState . lon ) ,
112
+ ] ,
113
+ ] ) ;
114
+ }
115
+ } , [ stop , locationState . status ] ) ;
102
116
103
117
if ( locationState . loadingPosition ) {
104
118
return < Loading /> ;
@@ -142,26 +156,12 @@ function StopPageMap(
142
156
}
143
157
const id = match . params . stopId || match . params . terminalId || match . params . id ;
144
158
145
- const mwtProps = { } ;
146
- if (
147
- locationState &&
148
- locationState . lat &&
149
- locationState . lon &&
150
- stop . lat &&
151
- stop . lon &&
152
- distance ( locationState , stop ) < maxShowRouteDistance
153
- ) {
154
- mwtProps . bounds = [
155
- [ locationState . lat , locationState . lon ] ,
156
- [
157
- stop . lat + ( stop . lat - locationState . lat ) ,
158
- stop . lon + ( stop . lon - locationState . lon ) ,
159
- ] ,
160
- ] ;
159
+ const mwtProps = { zoom : 18 } ;
160
+ if ( bounds ) {
161
+ mwtProps . bounds = bounds ;
161
162
} else {
162
163
mwtProps . lat = stop . lat ;
163
164
mwtProps . lon = stop . lon ;
164
- mwtProps . zoom = ! match . params . stopId || stop . platformCode ? 18 : 16 ;
165
165
}
166
166
167
167
return (
0 commit comments