Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2498 | - | 1 | |
2 | namespace GMap.NET.MapProviders |
||
3 | { |
||
4 | using System; |
||
5 | |||
6 | /// <summary> |
||
7 | /// BingHybridMap provider |
||
8 | /// </summary> |
||
9 | public class BingHybridMapProvider : BingMapProviderBase |
||
10 | { |
||
11 | public static readonly BingHybridMapProvider Instance; |
||
12 | |||
13 | BingHybridMapProvider() |
||
14 | { |
||
15 | } |
||
16 | |||
17 | static BingHybridMapProvider() |
||
18 | { |
||
19 | Instance = new BingHybridMapProvider(); |
||
20 | } |
||
21 | |||
22 | #region GMapProvider Members |
||
23 | |||
24 | readonly Guid id = new Guid("94E2FCB4-CAAC-45EA-A1F9-8147C4B14970"); |
||
25 | public override Guid Id |
||
26 | { |
||
27 | get |
||
28 | { |
||
29 | return id; |
||
30 | } |
||
31 | } |
||
32 | |||
33 | readonly string name = "BingHybridMap"; |
||
34 | public override string Name |
||
35 | { |
||
36 | get |
||
37 | { |
||
38 | return name; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | public override PureImage GetTileImage(GPoint pos, int zoom) |
||
43 | { |
||
44 | string url = MakeTileImageUrl(pos, zoom, LanguageStr); |
||
45 | |||
46 | return GetTileImageUsingHttp(url); |
||
47 | } |
||
48 | |||
49 | public override void OnInitialized() |
||
50 | { |
||
51 | base.OnInitialized(); |
||
52 | |||
53 | if(!DisableDynamicTileUrlFormat) |
||
54 | { |
||
55 | //UrlFormat[AerialWithLabels]: http://ecn.{subdomain}.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=3179&mkt={culture} |
||
56 | |||
57 | UrlDynamicFormat = GetTileUrl("AerialWithLabels"); |
||
58 | if(!string.IsNullOrEmpty(UrlDynamicFormat)) |
||
59 | { |
||
60 | UrlDynamicFormat = UrlDynamicFormat.Replace("{subdomain}", "t{0}").Replace("{quadkey}", "{1}").Replace("{culture}", "{2}"); |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | |||
65 | #endregion |
||
66 | |||
67 | string MakeTileImageUrl(GPoint pos, int zoom, string language) |
||
68 | { |
||
69 | string key = TileXYToQuadKey(pos.X, pos.Y, zoom); |
||
70 | |||
71 | if(!DisableDynamicTileUrlFormat && !string.IsNullOrEmpty(UrlDynamicFormat)) |
||
72 | { |
||
73 | return string.Format(UrlDynamicFormat, GetServerNum(pos, 4), key, language); |
||
74 | } |
||
75 | |||
76 | return string.Format(UrlFormat, GetServerNum(pos, 4), key, Version, language, ForceSessionIdOnTileAccess ? "&key=" + SessionId : string.Empty); |
||
77 | } |
||
78 | |||
79 | string UrlDynamicFormat = string.Empty; |
||
80 | |||
81 | // http://ecn.dynamic.t3.tiles.virtualearth.net/comp/CompositionHandler/12030012020203?mkt=en-us&it=A,G,L&n=z |
||
82 | |||
83 | static readonly string UrlFormat = "http://ecn.t{0}.tiles.virtualearth.net/tiles/h{1}.jpeg?g={2}&mkt={3}&n=z{4}"; |
||
84 | } |
||
85 | } |