-
Notifications
You must be signed in to change notification settings - Fork 697
/
WatercolorRasterTiles.js
executable file
·80 lines (68 loc) · 2.02 KB
/
WatercolorRasterTiles.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
import React from 'react';
import {View, StyleSheet} from 'react-native';
import MapboxGL from '@mapbox/react-native-mapbox-gl';
import {Slider} from 'react-native-elements';
import sheet from '../styles/sheet';
import colors from '../styles/colors';
import {SF_OFFICE_COORDINATE} from '../utils';
import Page from './common/Page';
import BaseExamplePropTypes from './common/BaseExamplePropTypes';
const styles = StyleSheet.create({
slider: {
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
maxHeight: 60,
paddingHorizontal: 24,
},
});
class WatercolorRasterTiles extends React.Component {
static propTypes = {
...BaseExamplePropTypes,
};
constructor(props) {
super(props);
this.state = {
opacity: 1,
};
this.onOpacityChange = this.onOpacityChange.bind(this);
}
onOpacityChange(value) {
this.setState({opacity: value});
}
render() {
const rasterSourceProps = {
id: 'stamenWatercolorSource',
url: 'https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg',
tileSize: 256,
};
return (
<Page {...this.props}>
<MapboxGL.MapView
zoomLevel={16}
centerCoordinate={SF_OFFICE_COORDINATE}
style={sheet.matchParent}
>
<MapboxGL.RasterSource {...rasterSourceProps}>
<MapboxGL.RasterLayer
id="stamenWatercolorLayer"
sourceID="stamenWatercolorSource"
style={{rasterOpacity: this.state.opacity}}
/>
</MapboxGL.RasterSource>
</MapboxGL.MapView>
<View style={styles.slider}>
<Slider
value={this.state.opacity}
onValueChange={this.onOpacityChange}
thumbTintColor={colors.primary.blue}
thumbTouchSize={{width: 44, height: 44}}
maximumTrackTintColor={colors.secondary.purpleLight}
minimumTrackTintColor={colors.secondary.purpleDark}
/>
</View>
</Page>
);
}
}
export default WatercolorRasterTiles;