/
Mapbox.cs
97 lines (75 loc) · 2.48 KB
/
Mapbox.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MissionPlanner.Maps
{
using System;
using GMap.NET.Projections;
using System.Globalization;
using GMap.NET.MapProviders;
using GMap.NET;
using System.Reflection;
using MissionPlanner.Utilities;
/// <summary>
/// EarthBuilder Custom
/// </summary>
public class MapBox : GMapProvider
{
public static readonly MapBox Instance;
MapBox()
{
MaxZoom = 24;
}
static MapBox()
{
Instance = new MapBox();
Type mytype = typeof (GMapProviders);
FieldInfo field = mytype.GetField("DbHash", BindingFlags.Static | BindingFlags.NonPublic);
Dictionary<int, GMapProvider> list = (Dictionary<int, GMapProvider>) field.GetValue(Instance);
list.Add(Instance.DbId, Instance);
}
#region GMapProvider Members
readonly Guid id = new Guid("22d6e496-842b-4549-bd6d-8f019e6c019f");
public override Guid Id
{
get { return id; }
}
readonly string name = "MapBox Satellite";
public override string Name
{
get { return name; }
}
GMapProvider[] overlays;
public override GMapProvider[] Overlays
{
get
{
if (overlays == null)
{
overlays = new GMapProvider[] {this};
}
return overlays;
}
}
public override PureProjection Projection
{
get { return MercatorProjection.Instance; }
}
public override PureImage GetTileImage(GPoint pos, int zoom)
{
string url = MakeTileImageUrl(pos, zoom, LanguageStr);
return GetTileImageUsingHttp(url);
}
#endregion
string MakeTileImageUrl(GPoint pos, int zoom, string language)
{
string ret;
ret = string.Format(CultureInfo.InvariantCulture, CustomURL, pos.X, pos.Y, zoom, mapsource, mapkey);
return ret;
}
public static string CustomURL = "http://a.tiles.mapbox.com/v4/{3}/{2}/{0}/{1}.png?access_token={4}";
public object mapsource = "mapbox.satellite";
public object mapkey = Settings.Instance.GetString("MapBoxAPIKey");
}
}