-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
BuildingExtrusionsExample.cs
145 lines (128 loc) · 4.11 KB
/
BuildingExtrusionsExample.cs
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
namespace MapboxMauiQs;
public class BuildingExtrusionsExample : ContentPage, IExamplePage, IQueryAttributable
{
MapboxView map;
IExampleInfo info;
Light light;
static readonly double[] firstPosition = new[] { 1.5, 90, 80 };
static readonly double[] secondPosition = new[] { 1.15, 210, 30 };
public BuildingExtrusionsExample()
{
iOSPage.SetUseSafeArea(this, false);
var content = new Grid
{
(map = new MapboxView()),
new ImageButton()
{
Source = "flashlight",
WidthRequest = 48,
HeightRequest = 48,
BackgroundColor = Colors.CadetBlue,
Command = new Command(ChangeLight),
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.End,
Margin = new Thickness(16,96),
Padding = new Thickness(8),
},
new ImageButton()
{
Source = "paintbrush",
WidthRequest = 48,
HeightRequest = 48,
BackgroundColor = Colors.CadetBlue,
Command = new Command(ChangeColor),
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.End,
Margin = new Thickness(16,96+48+16),
Padding = new Thickness(8),
}
};
Content = content;
light = new Light();
map.MapReady += Map_MapReady;
map.StyleLoaded += Map_StyleLoaded;
}
private void ChangeColor(object obj)
{
light.Color = light.Color == Colors.Red
? Colors.Blue
: Colors.Red;
map.Light = new Light
{
Color = light.Color,
Position = light.Position,
};
}
private void ChangeLight(object obj)
{
light.Position = light.Position == firstPosition
? secondPosition
: firstPosition;
map.Light = new Light
{
Color = light.Color,
Position = light.Position,
};
}
private void Map_StyleLoaded(object sender, EventArgs e)
{
var layer = new FillExtrusionLayer("3d-buildings")
{
Source = "composite",
MinZoom = 15,
SourceLayer = "building",
FillExtrusionColor = new PropertyValue<Color>(
Colors.LightGray
),
FillExtrusionOpacity = new PropertyValue<double>(0.6),
FillExtrusionAmbientOcclusionIntensity = new PropertyValue<double>(0.3),
FillExtrusionAmbientOcclusionRadius = new PropertyValue<double>(3.0),
Filter = DslExpression.Eq(
DslExpression.Get("extrude"),
"true"
),
FillExtrusionHeight = new PropertyValue<double>(
DslExpression.Interpolate(
DslExpression.Linear(),
DslExpression.Zoom(),
15,
0,
15.05,
DslExpression.Get("height")
)
),
FillExtrusionBase = new PropertyValue<double>(
DslExpression.Interpolate(
DslExpression.Linear(),
DslExpression.Zoom(),
15,
0,
15.05,
DslExpression.Get("min_height")
)
),
};
map.Layers = new List<MapboxLayer>
{
layer,
};
var center = new Point(40.7135, -74.0066);
var cameraOptions = new CameraOptions
{
Center = center,
Zoom = 15.5f,
Bearing = -17.6f,
Pitch = 45,
};
map.CameraOptions = cameraOptions;
}
private void Map_MapReady(object sender, EventArgs e)
{
map.MapboxStyle = MapboxStyle.LIGHT;
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
info = query["example"] as IExampleInfo;
Title = info?.Title;
}
}