Skip to content

Commit

Permalink
Polish before initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed Jan 3, 2020
1 parent 8399997 commit 34b4e11
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 244 deletions.
4 changes: 2 additions & 2 deletions src/BusBar/BusBar.js
Expand Up @@ -71,12 +71,12 @@ export default ({ setRoute, setProgress, progress, route }) => {
onPress={() => setRoute(route && route.value === line.value ? null : line)}
/>
))}

{/*
<BusButton
color="#555"
icon={progress ? "eye" : "eye-off"}
onPress={() => setProgress(!progress)}
/>
/> */}

</View>
)
Expand Down
26 changes: 20 additions & 6 deletions src/NTUMap/NTUMap.js
Expand Up @@ -32,6 +32,7 @@ export default ({ location, route, progress }) => {
const [busIcons, setBusIcons] = useState({})

const shotRef = useRef()
const cameraRef = useRef()

useLayoutEffect(() => {
(async () => {
Expand All @@ -43,17 +44,25 @@ export default ({ location, route, progress }) => {
})()
}, [])

useLayoutEffect(() => {
if (location && cameraRef.current) {
const { lat, lng } = location
cameraRef.current.flyTo([lng, lat], 1000)
}
}, [location])

return (
<Fragment>
<BusMarkerProvider ref={shotRef} />
<View style={styles.mapContainer}>
{mapReady ? (
<MapboxGL.MapView
style={styles.mapView}
styleURL={encodeURI(`https://raw.githubusercontent.com/delold/ntu-campus-map/f47ee4bcda3472935/style.json`)}
styleURL={encodeURI(
`https://raw.githubusercontent.com/delold/ntu-campus-map/f47ee4bcda3472935/style.json`,
)}
compassEnabled={false}
minZoomLevel={1}
>
minZoomLevel={1}>
<MapboxGL.Images
images={{
pin: pinIcon,
Expand All @@ -65,17 +74,22 @@ export default ({ location, route, progress }) => {
centerCoordinate: [103.68450164794922, 1.3484472784360202],
zoomLevel: 14.5,
}}
maxBounds={{
ne: [103.6820359, 1.1304753],
sw: [104.0120359, 1.4504753],
}}
ref={cameraRef}
/>

<BusRouteMarkers progress={progress} route={route} />
<TargetMarker location={location} />

<MapboxGL.UserLocation />
</MapboxGL.MapView>
) : (
<ActivityIndicator size="large" color="#D71440" />
)}
</View>
</Fragment>
)
);
}

0 comments on commit 34b4e11

Please sign in to comment.