Subversion Repositories Projects

Rev

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
   /// GoogleChinaHybridMap provider
8
   /// </summary>
9
   public class GoogleChinaHybridMapProvider : GoogleMapProviderBase
10
   {
11
      public static readonly GoogleChinaHybridMapProvider Instance;
12
 
13
      GoogleChinaHybridMapProvider()
14
      {
15
         RefererUrl = string.Format("http://ditu.{0}/", ServerChina);
16
      }
17
 
18
      static GoogleChinaHybridMapProvider()
19
      {
20
         Instance = new GoogleChinaHybridMapProvider();
21
      }
22
 
23
      public string Version = "h@298";
24
 
25
      #region GMapProvider Members
26
 
27
      readonly Guid id = new Guid("B8A2A78D-1C49-45D0-8F03-9B95C83116B7");
28
      public override Guid Id
29
      {
30
         get
31
         {
32
            return id;
33
         }
34
      }
35
 
36
      readonly string name = "GoogleChinaHybridMap";
37
      public override string Name
38
      {
39
         get
40
         {
41
            return name;
42
         }
43
      }
44
 
45
      GMapProvider[] overlays;
46
      public override GMapProvider[] Overlays
47
      {
48
         get
49
         {
50
            if(overlays == null)
51
            {
52
               overlays = new GMapProvider[] { GoogleChinaSatelliteMapProvider.Instance, this };
53
            }
54
            return overlays;
55
         }
56
      }
57
 
58
      public override PureImage GetTileImage(GPoint pos, int zoom)
59
      {
60
         string url = MakeTileImageUrl(pos, zoom, LanguageStr);
61
 
62
         return GetTileImageUsingHttp(url);
63
      }
64
 
65
      #endregion
66
 
67
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
68
      {
69
         string sec1 = string.Empty; // after &x=...
70
         string sec2 = string.Empty; // after &zoom=...
71
         GetSecureWords(pos, out sec1, out sec2);
72
 
73
         return string.Format(UrlFormat, UrlFormatServer, GetServerNum(pos, 4), UrlFormatRequest, Version, ChinaLanguage, pos.X, sec1, pos.Y, zoom, sec2, ServerChina);
74
      }
75
 
76
      static readonly string ChinaLanguage = "zh-CN";
77
      static readonly string UrlFormatServer = "mt";
78
      static readonly string UrlFormatRequest = "vt";
79
      static readonly string UrlFormat = "http://{0}{1}.{10}/{2}/imgtp=png32&lyrs={3}&hl={4}&gl=cn&x={5}{6}&y={7}&z={8}&s={9}";
80
   }
81
}