-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPolygonAnnotationExample.cs
75 lines (64 loc) · 2.33 KB
/
PolygonAnnotationExample.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
namespace MapboxMauiQs;
public class PolygonAnnotationExample : ContentPage, IExamplePage, IQueryAttributable
{
MapboxView map;
IExampleInfo info;
public PolygonAnnotationExample()
{
iOSPage.SetUseSafeArea(this, false);
Content = map = new MapboxView();
map.MapReady += Map_MapReady;
map.StyleLoaded += Map_StyleLoaded;
}
private void Map_MapReady(object sender, EventArgs e)
{
var centerLocation = new MapPosition(25.04579, -88.90136);
var cameraOptions = new CameraOptions
{
Center = centerLocation,
Zoom = 5,
};
map.CameraOptions = cameraOptions;
}
private void Map_StyleLoaded(object sender, EventArgs e)
{
var polygon = new Polygon(new[]
{
// outer ring
new LineString(
new [] {
new MapPosition(24.51713945052515, -89.857177734375 ),
new MapPosition(24.51713945052515, -87.967529296875 ),
new MapPosition(26.244156283890756, -87.967529296875) ,
new MapPosition(26.244156283890756, -89.857177734375) ,
new MapPosition(24.51713945052515, -89.857177734375 )
}
),
// inner ring
new LineString(
new [] {
new MapPosition(25.085598897064752, -89.20898437499999),
new MapPosition(25.085598897064752, -88.61572265625),
new MapPosition(25.720735134412106, -88.61572265625),
new MapPosition(25.720735134412106, -89.20898437499999),
new MapPosition(25.085598897064752, -89.20898437499999)
}
)
});
var polygonAnnotation = new PolygonAnnotation(polygon)
{
FillColor = Colors.Red,
FillOpacity = 0.8,
};
var polygonAnnotationManager = map.AnnotationController.CreatePolygonAnnotationManager(
Guid.NewGuid().ToString(),
LayerPosition.Unknown()
);
polygonAnnotationManager.AddAnnotations(polygonAnnotation);
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
info = query["example"] as IExampleInfo;
Title = info?.Title;
}
}