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
   /// GoogleChinaMap provider
8
   /// </summary>
9
   public class GoogleChinaMapProvider : GoogleMapProviderBase
10
   {
11
      public static readonly GoogleChinaMapProvider Instance;
12
 
13
      GoogleChinaMapProvider()
14
      {
15
         RefererUrl = string.Format("http://ditu.{0}/", ServerChina);
16
      }
17
 
18
      static GoogleChinaMapProvider()
19
      {
20
         Instance = new GoogleChinaMapProvider();
21
      }
22
 
23
      public string Version = "m@298";
24
 
25
      #region GMapProvider Members
26
 
27
      readonly Guid id = new Guid("1213F763-64EE-4AB6-A14A-D84D6BCC3426");
28
      public override Guid Id
29
      {
30
         get
31
         {
32
            return id;
33
         }
34
      }
35
 
36
      readonly string name = "GoogleChinaMap";
37
      public override string Name
38
      {
39
         get
40
         {
41
            return name;
42
         }
43
      }
44
 
45
      public override PureImage GetTileImage(GPoint pos, int zoom)
46
      {
47
         string url = MakeTileImageUrl(pos, zoom, LanguageStr);
48
 
49
         return GetTileImageUsingHttp(url);
50
      }
51
 
52
      #endregion
53
 
54
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
55
      {
56
         string sec1 = string.Empty; // after &x=...
57
         string sec2 = string.Empty; // after &zoom=...
58
         GetSecureWords(pos, out sec1, out sec2);
59
 
60
         return string.Format(UrlFormat, UrlFormatServer, GetServerNum(pos, 4), UrlFormatRequest, Version, ChinaLanguage, pos.X, sec1, pos.Y, zoom, sec2, ServerChina);
61
      }
62
 
63
      static readonly string ChinaLanguage = "zh-CN";
64
      static readonly string UrlFormatServer = "mt";
65
      static readonly string UrlFormatRequest = "vt";
66
      static readonly string UrlFormat = "http://{0}{1}.{10}/{2}/lyrs={3}&hl={4}&gl=cn&x={5}{6}&y={7}&z={8}&s={9}";
67
   }
68
}