-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstops_layer.js
93 lines (84 loc) · 2.13 KB
/
stops_layer.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
import React, {Component} from "react";
import {connect} from "react-redux";
import {StyleSheet, View} from "react-native";
import Mapbox from "@mapbox/react-native-mapbox-gl";
import {MIN_LABEL_LAYER_ID, EXCLUDE_ALL, INCLUDE_ALL} from "./constants";
import {getStopPoints, getSelectedItem} from "./selectors";
export function StopsLayer(props) {
const {stopPoints, filter} = props;
if (!stopPoints) {
return null;
}
return (
<View>
<Mapbox.ShapeSource
id="stop_symbols_source"
shape={stopPoints}
images={{
assets: ["stop"]
}}>
<Mapbox.SymbolLayer
id="stop_symbols_layer"
minZoomLevel={13}
filter={filter}
belowLayerID={MIN_LABEL_LAYER_ID}
style={mapStyles.stopSymbolsLayer}
/>
</Mapbox.ShapeSource>
<Mapbox.ShapeSource id="stop_points_source" shape={stopPoints}>
<Mapbox.CircleLayer
id="stop_points_layer"
maxZoomLevel={13}
filter={filter}
belowLayerID={MIN_LABEL_LAYER_ID}
style={mapStyles.stopPointsLayer}
/>
</Mapbox.ShapeSource>
</View>
);
}
export function mapStateToProps(state) {
const selectedItem = getSelectedItem(state);
let filter = INCLUDE_ALL;
if (
selectedItem &&
selectedItem.item &&
selectedItem.type === "stop" &&
state.selectedArrival
) {
filter = ["==", "stop_id", selectedItem.item.properties.stop_id];
} else if (!state.layerVisibility.stops) {
filter = EXCLUDE_ALL;
}
return {
filter,
stopPoints: getStopPoints(state)
};
}
export default connect(mapStateToProps)(StopsLayer);
const mapStyles = Mapbox.StyleSheet.create({
stopPointsLayer: {
circleColor: "#555555",
circleOpacity: 0.8,
circleRadius: Mapbox.StyleSheet.camera(
{
0: 0,
9: 1,
10: 1.2,
13: 3
},
Mapbox.InterpolationMode.Linear
)
},
stopSymbolsLayer: {
iconImage: "marker-15",
iconAllowOverlap: true,
iconSize: Mapbox.StyleSheet.camera(
{
13: 0.5,
18: 1.5
},
Mapbox.InterpolationMode.Linear
)
}
});