-
-
Notifications
You must be signed in to change notification settings - Fork 839
/
ChoroplethLayerByZoomLevel.js
executable file
·109 lines (98 loc) · 2.15 KB
/
ChoroplethLayerByZoomLevel.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React from 'react';
import Mapbox from '@rnmapbox/maps';
import sheet from '../../styles/sheet';
const styles = {
statePopulation: {
fillColor: [
'interpolate',
['linear'],
['get', 'population'],
0,
'#F2F12D',
500000,
'#EED322',
750000,
'#E6B71E',
1000000,
'#DA9C20',
2500000,
'#CA8323',
5000000,
'#B86B25',
7500000,
'#A25626',
10000000,
'#8B4225',
25000000,
'#723122',
],
fillOpacity: 0.75,
},
countyPopulation: {
fillColor: [
'interpolate',
['linear'],
['get', 'population'],
0,
'#F2F12D',
100,
'#EED322',
1000,
'#E6B71E',
5000,
'#DA9C20',
10000,
'#CA8323',
50000,
'#B86B25',
100000,
'#A25626',
500000,
'#8B4225',
1000000,
'#723122',
],
fillOpacity: 0.75,
},
};
class ChoroplethLayerByZoomLevel extends React.PureComponent {
render() {
return (
<Mapbox.MapView
styleURL={Mapbox.StyleURL.Light}
style={sheet.matchParent}
>
<Mapbox.Camera
centerCoordinate={[-98, 38.88]}
zoomLevel={3}
minZoomLevel={3}
/>
<Mapbox.VectorSource id="population" url={'mapbox://mapbox.660ui7x6'}>
<Mapbox.FillLayer
id="state-population"
sourceLayerID="state_county_population_2014_cen"
maxZoomLevel={4}
filter={['==', 'isState', true]}
style={styles.statePopulation}
/>
<Mapbox.FillLayer
id="county-population"
sourceLayerID="state_county_population_2014_cen"
minZoomLevel={4}
filter={['==', 'isCounty', true]}
style={styles.countyPopulation}
/>
</Mapbox.VectorSource>
</Mapbox.MapView>
);
}
}
export default ChoroplethLayerByZoomLevel;
/* end-example-doc */
/** @type ExampleWithMetadata['metadata'] */
const metadata = {
title: 'Choropleth Layer By Zoom Level',
tags: ['VectorSource'],
docs: '',
};
ChoroplethLayerByZoomLevel.metadata = metadata;