-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
55 lines (49 loc) · 1.24 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { useEffect } from 'react';
import { StyleSheet, View, ActivityIndicator, Text } from 'react-native';
import MapLibreGL from '@maplibre/maplibre-react-native';
import { useTileManager } from './hooks/useTileManager';
export default function App() {
const { tileManager, isLoading, error } = useTileManager();
useEffect(() => {
MapLibreGL.setAccessToken(null);
}, []);
if (isLoading) {
return <ActivityIndicator />;
}
if (error) {
return (
<View style={styles.errorContainer}>
<Text style={styles.errorText}>Error: {error.message}</Text>
</View>
);
}
return (
<View style={styles.container}>
<MapLibreGL.MapView
style={styles.map}
styleURL={tileManager.getStyleUrl()}
testID="map-view"
>
<MapLibreGL.Camera
zoomLevel={9}
centerCoordinate={[-73.72826520392081, 45.584043985983]}
minZoomLevel={5}
maxZoomLevel={10}
/>
</MapLibreGL.MapView>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1 },
map: { flex: 1 },
errorContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
errorText: {
color: 'red',
fontSize: 16,
},
});