-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathAddOneMarkerSymbolExample.cs
64 lines (50 loc) · 1.76 KB
/
AddOneMarkerSymbolExample.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
namespace MapboxMauiQs;
public class AddOneMarkerSymbolExample : ContentPage, IExamplePage, IQueryAttributable
{
MapboxView map;
IExampleInfo info;
public AddOneMarkerSymbolExample()
{
iOSPage.SetUseSafeArea(this, false);
Content = map = new MapboxView();
map.MapReady += Map_MapReady;
map.StyleLoaded += Map_StyleLoaded;
}
private void Map_StyleLoaded(object sender, EventArgs e)
{
const string imageId = @"BLUE_ICON_ID";
const string imageName = @"blue_marker_view";
const string sourceId = @"SOURCE_ID";
var image = new ResolvedImage(imageId, imageName);
map.Images = new[] { image };
var source = new GeoJSONSource(sourceId)
{
Data = new GeoJSON.Text.Geometry.Point(
new MapPosition(55.665957, 12.550343))
};
map.Sources = new[] { source };
var layer = new SymbolLayer(@"LAYER_ID", sourceId)
{
IconImage = new PropertyValue<ResolvedImage>(image),
IconAnchor = IconAnchor.Bottom,
IconOffset = new PropertyValue<double[]>(new double [] { 0.0, 12.0 }),
};
map.Layers = new[] { layer };
}
private void Map_MapReady(object sender, EventArgs e)
{
// Do any additional setup after loading the view.
var center = new MapPosition(55.665957, 12.550343);
var cameraOptions = new CameraOptions {
Center = center,
Zoom = 8,
};
map.CameraOptions = cameraOptions;
map.MapboxStyle = MapboxStyle.STANDARD;
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
info = query["example"] as IExampleInfo;
Title = info?.Title;
}
}