-
-
Notifications
You must be signed in to change notification settings - Fork 937
Expand file tree
/
Copy pathStyleLayerProperty.js
More file actions
executable file
·65 lines (56 loc) · 1.4 KB
/
StyleLayerProperty.js
File metadata and controls
executable file
·65 lines (56 loc) · 1.4 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, Camera } from '@rnmapbox/maps';
import Bubble from '../common/Bubble';
const defaultCamera = {
centerCoordinate: [-74.005974, 40.712776],
zoomLevel: 13,
};
const styles = {
mapView: { flex: 1 },
};
class StyleLayerProperty extends React.Component {
state = {
show: true,
};
onPress = () => {
this.setState(
{
show: !this.state.show,
},
() => {
this._map.setStyleLayerProperty('building', 'visibility', this.state.show ? 'visible' : 'none');
},
);
};
render() {
return (
<>
<MapView
ref={(c) => {
this._map = c;
}}
onPress={this.onPress}
style={styles.mapView}
>
<Camera defaultSettings={defaultCamera} />
</MapView>
<Bubble onPress={this.onPress}>
<Text>{this.state.show ? 'Hide Buildings' : 'Show Buildings'}</Text>
</Bubble>
</>
);
}
}
export default StyleLayerProperty;
/* end-example-doc */
/**
* @typedef {import('../common/ExampleMetadata').ExampleWithMetadata} ExampleWithMetadata
* @type {ExampleWithMetadata['metadata']}
*/
const metadata = {
title: 'Style Layer Property',
tags: ['MapView#setStyleLayerProperty'],
docs: `Changes the property of a layer using the specified layerId`,
};
StyleLayerProperty.metadata = metadata;