-
Notifications
You must be signed in to change notification settings - Fork 2
/
style.js
52 lines (47 loc) · 1.01 KB
/
style.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
// https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/EXAMPLES.md as
// reference
const roundedLine = {
"line-cap": "round",
"line-join": "round",
};
export const isPolygon = ["==", "$type", "Polygon"];
export const isLine = ["==", "$type", "LineString"];
export const isPoint = ["==", "$type", "Point"];
export function drawLine(color, width, opacity = 1.0) {
return {
type: "line",
layout: roundedLine,
paint: {
"line-color": color,
"line-width": width,
"line-opacity": opacity,
},
};
}
export function drawPolygon(color, opacity) {
return {
type: "fill",
paint: {
"fill-color": color,
"fill-opacity": opacity,
},
};
}
export function drawCircle(
color,
radius,
outlineColor,
outlineWidth,
opacity = 1.0
) {
return {
type: "circle",
paint: {
"circle-radius": radius,
"circle-color": color,
"circle-opacity": opacity,
"circle-stroke-color": outlineColor,
"circle-stroke-width": outlineWidth,
},
};
}