forked from Mapsui/Mapsui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.cs
More file actions
66 lines (56 loc) · 1.91 KB
/
ViewController.cs
File metadata and controls
66 lines (56 loc) · 1.91 KB
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
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using Mapsui.UI.iOS;
using UIKit;
using CoreGraphics;
using Mapsui.UI;
using Mapsui.Providers;
using Mapsui.Samples.Common.Helpers;
using Mapsui.Samples.Common.Maps;
namespace Mapsui.Samples.iOS
{
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Hack to tell the platform independent samples where the files can be found on iOS.
MbTilesSample.MbTilesLocation = MbTilesLocationOnIos;
// Never tested this. PDD.
MbTilesHelper.DeployMbTilesFile(s => File.Create(Path.Combine(MbTilesLocationOnIos, s)));
var mapControl = CreateMap(View.Bounds);
mapControl.Info += MapOnInfo;
View = mapControl;
}
private void MapOnInfo(object sender, MapInfoEventArgs e)
{
if (e.MapInfo.Feature == null) return;
Debug.WriteLine(ToString(e.MapInfo.Feature));
}
private string ToString(IFeature feature)
{
var result = new StringBuilder();
foreach (var field in feature.Fields)
{
result.Append($"{field}={feature[field]}, ");
}
result.Append($"Geometry={feature.Geometry}");
return result.ToString();
}
private static MapControl CreateMap(CGRect bounds)
{
return new MapControl(bounds)
{
Map = InfoLayersSample.CreateMap(),
UnSnapRotationDegrees = 30,
ReSnapRotationDegrees = 5
};
}
private static string MbTilesLocationOnIos => Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
}