-
Notifications
You must be signed in to change notification settings - Fork 694
/
Copy pathEarthQuakes.js
executable file
·99 lines (87 loc) · 2.39 KB
/
EarthQuakes.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
import React from 'react';
import MapboxGL from '@mapbox/react-native-mapbox-gl';
import sheet from '../styles/sheet';
import {SF_OFFICE_COORDINATE} from '../utils';
import BaseExamplePropTypes from './common/BaseExamplePropTypes';
import Page from './common/Page';
const layerStyles = MapboxGL.StyleSheet.create({
singlePoint: {
circleColor: 'green',
circleOpacity: 0.84,
circleStrokeWidth: 2,
circleStrokeColor: 'white',
circleRadius: 5,
circlePitchAlignment: 'map',
},
clusteredPoints: {
circlePitchAlignment: 'map',
circleColor: MapboxGL.StyleSheet.source(
[
[25, 'yellow'],
[50, 'red'],
[75, 'blue'],
[100, 'orange'],
[300, 'pink'],
[750, 'white'],
],
'point_count',
MapboxGL.InterpolationMode.Exponential,
),
circleRadius: MapboxGL.StyleSheet.source(
[[0, 15], [100, 20], [750, 30]],
'point_count',
MapboxGL.InterpolationMode.Exponential,
),
circleOpacity: 0.84,
circleStrokeWidth: 2,
circleStrokeColor: 'white',
},
clusterCount: {
textField: '{point_count}',
textSize: 12,
textPitchAlignment: 'map',
},
});
class EarthQuakes extends React.Component {
static propTypes = {
...BaseExamplePropTypes,
};
render() {
return (
<Page {...this.props}>
<MapboxGL.MapView
zoomLevel={6}
pitch={45}
centerCoordinate={SF_OFFICE_COORDINATE}
style={sheet.matchParent}
styleURL={MapboxGL.StyleURL.Dark}
>
<MapboxGL.ShapeSource
id="earthquakes"
cluster
clusterRadius={50}
clusterMaxZoom={14}
url="https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson"
>
<MapboxGL.SymbolLayer
id="pointCount"
style={layerStyles.clusterCount}
/>
<MapboxGL.CircleLayer
id="clusteredPoints"
belowLayerID="pointCount"
filter={['has', 'point_count']}
style={layerStyles.clusteredPoints}
/>
<MapboxGL.CircleLayer
id="singlePoint"
filter={['!has', 'point_count']}
style={layerStyles.singlePoint}
/>
</MapboxGL.ShapeSource>
</MapboxGL.MapView>
</Page>
);
}
}
export default EarthQuakes;