-
-
Notifications
You must be signed in to change notification settings - Fork 950
Expand file tree
/
Copy pathChangeLayerColor.js
More file actions
65 lines (56 loc) · 1.41 KB
/
Copy pathChangeLayerColor.js
File metadata and controls
65 lines (56 loc) · 1.41 KB
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
import React from 'react';
import { Text } from 'react-native';
import { MapView, FillLayer, Camera } from '@rnmapbox/maps';
import Bubble from '../common/Bubble';
const defaultCamera = {
centerCoordinate: [12.338, 45.4385],
zoomLevel: 17.4,
};
const styles = {
mapView: { flex: 1 },
};
class ChangeLayerColor extends React.Component {
state = {
fillColor: '',
};
onPress = () => {
const fillColor = `#${Math.random().toString(16).substr(-6)}`;
this.setState({ fillColor });
};
render() {
const { fillColor } = this.state;
return (
<>
<MapView
ref={(c) => {
this._map = c;
}}
onPress={this.onPress}
style={styles.mapView}
>
<Camera defaultSettings={defaultCamera} />
{!!fillColor && (
<FillLayer id="water" existing style={{ fillColor }} />
)}
</MapView>
<Bubble onPress={this.onPress}>
<Text>Paint Water</Text>
</Bubble>
</>
);
}
}
export default ChangeLayerColor;
/* end-example-doc */
/**
* @typedef {import('../common/ExampleMetadata').ExampleWithMetadata} ExampleWithMetadata
* @type {ExampleWithMetadata['metadata']}
*/
const metadata = {
title: 'Change Layer Color',
tags: ['FillLayer#existing', 'FillLayer#fillColor'],
docs: `
Change style of a layer part of the map on the fly.
`,
};
ChangeLayerColor.metadata = metadata;