public string getCoords(CellTower ct) { try { String url = "http://www.google.com/glm/mmap"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(url)); req.Method = "POST"; byte[] pd = PostData(ct.getMobileCountryCode(), ct.getMobileNetworkCode(), ct.getLocationAreaCode(), ct.getTowerId(), false); 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]; System.Diagnostics.Debug.Assert(opcode1 == 0x0e); System.Diagnostics.Debug.Assert(opcode2 == 0x1b); int ret_code = (int)((ps[3] << 24) | (ps[4] << 16) | (ps[5] << 8) | (ps[6])); if (ret_code == 0) { double tlat = ((double)((ps[7] << 24) | (ps[8] << 16) | (ps[9] << 8) | (ps[10]))) / 1000000; double tlon = ((double)((ps[11] << 24) | (ps[12] << 16) | (ps[13] << 8) | (ps[14]))) / 1000000; lat = tlat; lng = tlon; return (tlat + "," + tlon); } else { return null; } } else { return null; } } catch (Exception) { return null; } }