-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomStyle.js
81 lines (75 loc) · 1.9 KB
/
CustomStyle.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
71
72
73
74
75
76
77
78
79
80
81
import React, {useState} from 'react';
import {StyleSheet, View, TextInput, Button} from 'react-native';
import MapLibreGL from '@react-native-mapbox-gl/maps';
import {accessToken, customStyle} from '../../config';
const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
container: {
width: '100%',
height: '100%',
backgroundColor: 'white',
},
topBar: {
height: 60,
display: 'flex',
flexDirection: 'row',
padding: 10,
},
tokenInput: {
height: 40,
flex: 2,
borderWidth: 1,
padding: 10,
marginRight: 10,
color: 'black',
},
updateButton: {
height: 40,
padding: 10,
},
map: {
flex: 1,
},
});
const CustomStyle = () => {
const [style, setStyle] = useState(customStyle);
const [input, updateInput] = useState('');
return (
<View style={styles.page}>
<View style={styles.container}>
<View style={styles.topBar}>
<TextInput
style={styles.tokenInput}
onChangeText={newInput => updateInput(newInput.trim())}
defaultValue={customStyle}
placeholder={'enter your custom style name'}
/>
<Button
style={styles.updateButton}
title={'Update'}
onPress={() => setStyle(input)}
/>
</View>
<MapLibreGL.MapView
style={styles.map}
logoEnabled={false}
attributionEnabled={true}
attributionPosition={{bottom: 8, left: 8}}
styleURL={`https://api.jawg.io/styles/${style}.json?access-token=${accessToken}`}>
<MapLibreGL.Camera
defaultSettings={{
centerCoordinate: [2.3210938, 48.7965913],
zoomLevel: 2,
}}
/>
</MapLibreGL.MapView>
</View>
</View>
);
};
export default CustomStyle;