-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChangeStyle.js
70 lines (64 loc) · 1.6 KB
/
ChangeStyle.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, {useState} from 'react';
import {StyleSheet, View} from 'react-native';
import MapLibreGL from '@react-native-mapbox-gl/maps';
import SelectDropdown from 'react-native-select-dropdown';
import {accessToken} from '../../config';
const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
container: {
width: '100%',
height: '100%',
backgroundColor: 'white',
},
map: {
flex: 1,
},
menu: {
height: 40,
width: '100%',
},
});
const ChangeStyle = () => {
const jawgStyles = [
'jawg-streets',
'jawg-sunny',
'jawg-terrain',
'jawg-dark',
'jawg-light',
];
const [style, setStyle] = useState(jawgStyles[0]);
return (
<View style={styles.page}>
<View style={styles.container}>
<SelectDropdown
buttonStyle={styles.menu}
data={jawgStyles}
defaultValueByIndex={0}
rowStyle={{
height: 40,
}}
onSelect={(selectedItem, _) => setStyle(selectedItem)}
/>
<MapLibreGL.MapView
style={styles.map}
logoEnabled={false}
attributionEnabled={true}
attributionPosition={{bottom: 8, left: 8}}
styleURL={`https://api.jawg.io/styles/${style}.json?lang=en&access-token=${accessToken}`}>
<MapLibreGL.Camera
defaultSettings={{
centerCoordinate: [35.51, 33.88],
zoomLevel: 12,
}}
/>
</MapLibreGL.MapView>
</View>
</View>
);
};
export default ChangeStyle;