发布:2015/9/5 0:39:42作者:管理员 来源:本站 浏览次数:1288
private void button1_Click(object sender, EventArgs e)
{
string address = "北京";
string output = "csv";
string key = "ABQIAAAAXDq__hWKi9eMCwnn7LrMCxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSnSVp_Xlsd4Ph5iyMua7PE5E0x_A";
string url = string.Format("http://ditu.google.cn/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());
string[] tmpArray = sr.ReadToEnd().Split(',');
string latitude = tmpArray[2];
string longitude = tmpArray[3];
MessageBox.Show(string.Format("纬度: {0}, 经度: {1}", latitude, longitude), address, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4