/// <summary>
       /// 通过基站信息获取经纬度
       /// </summary>
       /// <param name="args"></param>
       /// <returns></returns>
        static public string GetLatLng(string[] args)  
       {  
            if (args.Length < 4)  
            {  
                return string.Empty;  
            }  
            string shortCID = "";   /* Default, no change at all */  
            if (args.Length == 5)  
                shortCID = args[4].ToLower();  
            try  
            {  
                String url = "http://www.google.com/glm/mmap";  
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(  
                    new Uri(url));  
                req.Method = "POST";  
 
                int MCC = Convert.ToInt32(args[0]);  
                int MNC = Convert.ToInt32(args[1]);  
                int LAC = Convert.ToInt32(args[2]);  
                int CID = Convert.ToInt32(args[3]);  
                byte[] pd = PostData(MCC, MNC, LAC, CID,  
                    shortCID == "shortcid");  
 
                req.ContentLength = pd.Length;  
                req.ContentType = "application/binary";  
                Stream outputStream = req.GetRequestStream();  
                outputStream.Write(pd, 0, pd.Length);  
                outputStream.Close();  
 
                HttpWebResponse res = (HttpWebResponse)req.GetResponse();  
                byte[] ps = new byte[res.ContentLength];  
                int totalBytesRead = 0;  
                while (totalBytesRead < ps.Length)  
                {  
                    totalBytesRead += res.GetResponseStream().Read(  
                        ps, totalBytesRead, ps.Length - totalBytesRead);  
                }  
 
                if (res.StatusCode == HttpStatusCode.OK)  
               {  
                    short opcode1 = (short)(ps[0] << 8 | ps[1]);  
                    byte opcode2 = ps[2];  
                    int ret_code = (int)((ps[3] << 24) | (ps[4] << 16) |  
                                   (ps[5] << 8) | (ps[6]));  
                    if (ret_code == 0)  
                  {  
                        double lat = ((double)((ps[7] << 24) | (ps[8] << 16)  
                                     | (ps[9] << 8) | (ps[10]))) / 1000000;  
                        double lon = ((double)((ps[11] << 24) | (ps[12] <<  
                                     16) | (ps[13] << 8) | (ps[14]))) /  
                                     1000000;  
                        return lat + "|" + lon;  
                    }  
                    else  
                        return string.Empty;  
                }  
                else  
                    return string.Empty;  
            }  
            catch (Exception ex)  
            {  
                MessageBox.Show(ex.ToString());  
                return string.Empty;  
            }  
        }      } 1  /// <summary>
 2         /// 判断是否正确获取经纬度信息
 3         /// </summary>
 4         /// <param name="cellid">cellid</param>
 5         /// <param name="lac">LocationAreaCode</param>
 6         /// <param name="Lat">latitude</param>
 7         /// <param name="Lng">longgitude</param>
 8         /// <returns></returns>
 9         public static bool LocateGooleMapApi(uint cellid, uint lac, out double Lat, out double Lng)
10         {
11             HttpWebRequest request =(HttpWebRequest)WebRequest.Create("http://www.google.com/glm/mmap");
12             request.Method = "POST";
13 
14          
15             byte[] byteArray = {0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 
16                         0x65, 0x6E, // en
17                         0x00, 0x07, 
18                         0x41, 0x6E, 0x64, 0x72, 0x6F, 0x69, 0x64, 
19                         0x00, 0x03, 
20                         0x31, 0x2E, 0x30, // 1.0
21                         0x00, 0x03, 
22                         0x57, 0x65, 0x62, // web
23                         0x1B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
24                         0x00,0x00,0x00,0x00,0x03,0x00,0x00, 
25                         0xFF, 0xFF, 0xFF, 0xFF, // CellID
26                         0xFF, 0xFF, 0xFF, 0xFF, // LAC
27                         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
28                         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
29 
30             // write CellID
31             byte[] intByte = BitConverter.GetBytes(cellid);
32             byteArray[48] = intByte[3];
33             byteArray[49] = intByte[2];
34             byteArray[50] = intByte[1];
35             byteArray[51] = intByte[0];
36 
37             // write LAC
38             intByte = BitConverter.GetBytes(lac);
39             byteArray[52] = intByte[3];
40             byteArray[53] = intByte[2];
41             byteArray[54] = intByte[1];
42             byteArray[55] = intByte[0];
43 
44             // set request
45             request.ContentLength = byteArray.Length;
46             Stream postStream = request.GetRequestStream();
47             postStream.Write(byteArray, 0, byteArray.Length);
48             postStream.Close();
49 
50             // Get the response.
51             HttpWebResponse response = (HttpWebResponse)request.GetResponse();
52             Console.WriteLine("[I] Request response: {0}", response.StatusDescription);
53 
54             // Read response
55             Stream dataStream = response.GetResponseStream();
56             BinaryReader BR = new BinaryReader(dataStream);
57             // skip 3 byte
58             BR.ReadByte();
59             BR.ReadByte();
60             BR.ReadByte();
61 
62             // check state
63             if (0 == BR.ReadInt32())
64             {
65                 // read lat
66                 byte[] tmpByte = new byte[4];
67                 tmpByte[3] = BR.ReadByte();
68                 tmpByte[2] = BR.ReadByte();
69                 tmpByte[1] = BR.ReadByte();
70                 tmpByte[0] = BR.ReadByte();
71                 Lat = (double)(BitConverter.ToInt32(tmpByte, 0)) / 1000000D;
72 
73                 // read lng
74                 tmpByte[3] = BR.ReadByte();
75                 tmpByte[2] = BR.ReadByte();
76                 tmpByte[1] = BR.ReadByte();
77                 tmpByte[0] = BR.ReadByte();
78                 Lng = (double)(BitConverter.ToInt32(tmpByte, 0)) / 1000000D;
79 
80                 BR.Close();
81                 dataStream.Close();
82                 response.Close();
83                 return true;
84             }
85             else
86             {
87                 BR.Close();
88                 dataStream.Close();
89                 response.Close();
90                 Lat = 0;
91                 Lng = 0;
92                 return false;
93             }
94 
95 
96         } 1       Cursor.Current = Cursors.WaitCursor;
 2             string [] cellidFields = RIL.GetCellTowerInfo().ToString().Split("-");
 3               
 4             string[] args ={
 5                                cellidFields[2],
 6                                "0",
 7                                cellidFields[1],
 8                                cellidFields[0]
 9                            };
10             string[] latlng = GMM.GetLatLng(args).Split("|");
11 
12             Uri url = new Uri("http://maps.google.com/staticmap?&maptype=satellite&key=xxx&ers=" + latlng[0].ToString().Replace(",", ".") + "," + latlng[1].ToString().Replace(",", ".") + "&center=,&size=240x320&zoom=18");
13             webBrowser1.Navigate(url);
14             Cursor.Current = Cursors.Default;