File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed
Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,5 @@ declare module '@env' {
33 export const GTFS_API_GATEWAY_KEY : string ;
44 export const WEBSOCKET_GATEWAY_URL : string ;
55 export const MAPBOX_ACCESS_TOKEN : string ;
6+ export const MAPBOX_STYLE_URL : string ;
67}
Original file line number Diff line number Diff line change @@ -2,33 +2,42 @@ import React, { FC } from 'react';
22import { StyleSheet } from 'react-native' ;
33import MapboxGL from '@react-native-mapbox-gl/maps' ;
44import { Coordinate } from 'interfaces' ;
5- import { MAPBOX_ACCESS_TOKEN } from '@env' ;
5+ import { MAPBOX_ACCESS_TOKEN , MAPBOX_STYLE_URL } from '@env' ;
66
77type Props = {
88 centerCoordinate : Coordinate ;
99 zoomLevel : number ;
1010 pitch : number ;
1111 children : any ;
12+ onRegionWillChange ?: ( ) => void ;
13+ onRegionDidChange ?: ( ) => void ;
1214} ;
1315
1416MapboxGL . setAccessToken ( MAPBOX_ACCESS_TOKEN ) ;
1517
16- const ANIMATION_DURATION = 1500 ;
17- const styleURL = 'mapbox://styles/jurevans/ckx09yl8v07tm14rupxmhhz3o' ;
18-
18+ const ANIMATION_DURATION = 1000 ;
1919const styles = StyleSheet . create ( {
2020 map : {
2121 flex : 1 ,
2222 } ,
2323} ) ;
2424
25- const Map : FC < Props > = ( { centerCoordinate, zoomLevel, pitch, children } ) => {
25+ const Map : FC < Props > = ( {
26+ centerCoordinate,
27+ zoomLevel,
28+ pitch,
29+ onRegionWillChange,
30+ onRegionDidChange,
31+ children,
32+ } ) => {
2633 return (
2734 < MapboxGL . MapView
28- styleURL = { styleURL }
35+ styleURL = { MAPBOX_STYLE_URL || MapboxGL . StyleURL . Dark }
2936 pitchEnabled = { true }
3037 logoEnabled = { false }
3138 compassEnabled = { true }
39+ onRegionWillChange = { onRegionWillChange }
40+ onRegionDidChange = { onRegionDidChange }
3241 style = { styles . map } >
3342 < MapboxGL . Camera
3443 zoomLevel = { zoomLevel }
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ import { StopTimeCallback } from 'components/StopTime';
2323const DEFAULT_COORD : Coordinate = [ - 73.94594865587045 , 40.7227534777328 ] ;
2424const DEFAULT_ZOOM = 11 ;
2525const STOP_ZOOM = 15 ;
26- const ANIMATION_DURATION = 1500 ;
2726
2827interface ShapeVars {
2928 shapeId : string ;
@@ -83,8 +82,6 @@ const MapScreen: FC = () => {
8382 stopId : stopId ,
8483 } ) ,
8584 ) ;
86- setMarkerVisible ( false ) ;
87- setTimeout ( ( ) => setMarkerVisible ( true ) , ANIMATION_DURATION ) ;
8885 } ,
8986 [ dispatch ] ,
9087 ) ;
@@ -95,7 +92,7 @@ const MapScreen: FC = () => {
9592 centerCoordinate : stop ?. geom . coordinates || DEFAULT_COORD ,
9693 zoomLevel : STOP_ZOOM ,
9794 } ) ) ;
98- } , [ stop ?. geom . coordinates ] ) ;
95+ } , [ stop ] ) ;
9996
10097 const shapeLayerId = `line-layer-${ trip ?. feedIndex } :${ trip ?. tripId } ` ;
10198
@@ -105,7 +102,9 @@ const MapScreen: FC = () => {
105102 < Map
106103 centerCoordinate = { centerCoordinate }
107104 zoomLevel = { zoomLevel }
108- pitch = { pitch } >
105+ pitch = { pitch }
106+ onRegionWillChange = { ( ) => setMarkerVisible ( false ) }
107+ onRegionDidChange = { ( ) => setMarkerVisible ( true ) } >
109108 { stop ?. geom && isMarkerVisible && (
110109 < StopMarker
111110 feedIndex = { stop . feedIndex }
You can’t perform that action at this time.
0 commit comments