string address = "哈尔滨市"; string output = "csv"; string key = "ABQIAAAAXitC6yREC7A_5d5rzWd2WRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRNbLLBGwZQV2smqnezM8aBlk9s0w"; string url = string.Format("http://maps.google.com/maps/geo?q={0}&output={1}&key={2}", address, output, key); // 送出要求 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); //取得回应 HttpWebResponse response = (HttpWebResponse) request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); // 解析 200,8,25.033408,121.564099 (HTTP status code, accuracy, latitude, longitude) //readtoend 表示字符串形式的流的其余部分(从当前位置到末尾)。如果当前位置位于流的末尾,则返回空字符串 ("")。 string[] tmpArray = sr.ReadToEnd().Split(','); string latitude = tmpArray[2]; string longitude = tmpArray[3]; Response.Write(string.Format("緯度: {0}, 經度: {1}", latitude, longitude));