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 © 广州京杭网络科技有限公司 2005-2024 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有