-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CircleAnnotationExample.cs
63 lines (53 loc) · 1.75 KB
/
CircleAnnotationExample.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
namespace MapboxMauiQs;
public class CircleAnnotationExample : ContentPage, IExamplePage, IQueryAttributable
{
MapboxView map;
IExampleInfo info;
public CircleAnnotationExample()
{
iOSPage.SetUseSafeArea(this, false);
Content = map = new MapboxView();
map.MapReady += Map_MapReady;
map.MapLoaded += Map_MapLoaded;
}
private void Map_MapLoaded(object sender, EventArgs e)
{
var random = new Random();
var circleAnnotations = new List<CircleAnnotation>();
for (int i = 0; i < 2000; i++)
{
var center = new Point(
random.NextInt64(0, 180) - 90,
random.NextInt64(0, 360) - 180);
var color = new Color(
random.Next(0, 255),
random.Next(0, 255),
random.Next(0, 255));
var circleAnnotation = new CircleAnnotation(
new GeoJSON.Text.Geometry.Point(
new Position(center.X, center.Y)
)
)
{
CircleColor = color,
CircleRadius = 12,
IsDraggable = true,
};
circleAnnotations.Add(circleAnnotation);
}
var circleAnnotationManager = map.AnnotationController.CreateCircleAnnotationManager(
Guid.NewGuid().ToString(),
LayerPosition.Unknown()
);
circleAnnotationManager.AddAnnotations(circleAnnotations.ToArray());
}
private void Map_MapReady(object sender, EventArgs e)
{
// Setup Map here
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
info = query["example"] as IExampleInfo;
Title = info?.Title;
}
}