亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

c# 通過(guò)經(jīng)緯度查詢 具體的地址和區(qū)域名稱

 更新時(shí)間:2012年11月21日 11:11:55   作者:  
最近項(xiàng)目需要通過(guò)經(jīng)緯度查詢 具體的地址和區(qū)域名稱,通過(guò)查詢網(wǎng)絡(luò)資源,發(fā)現(xiàn)提供的大多是得到具體的地址而對(duì)區(qū)域或城市名稱的獲取就不是很好把握;在這里自己搞了個(gè),需要的朋友可以參考下
最近項(xiàng)目需要通過(guò)經(jīng)緯度查詢 具體的地址和區(qū)域名稱,通過(guò)查詢網(wǎng)絡(luò)資源,發(fā)現(xiàn)提供的大多是得到具體的地址而對(duì)區(qū)域或城市名稱的獲取就不是很好把握;在這里自己搞了個(gè):
復(fù)制代碼 代碼如下:

//webclient客戶端對(duì)象
WebClient client = new WebClient();
string url = "http://maps.google.com/maps/api/geocode/xml?latlng=" + latitude + "," + longitude + "&language=zh-CN&sensor=false";//請(qǐng)求地址
client.Encoding = Encoding.UTF8;//編碼格式
string responseTest = client.DownloadString(url);
//下載xml響應(yīng)數(shù)據(jù)
string address = "";//返回的地址
XmlDocument doc = new XmlDocument();
//創(chuàng)建XML文檔對(duì)象
if (!string.IsNullOrEmpty(responseTest))
{
doc.LoadXml(responseTest);//加載xml字符串
//查詢狀態(tài)信息
string xpath = @"GeocodeResponse/status";
XmlNode node = doc.SelectSingleNode(xpath);
string status = node.InnerText.ToString();
if (status == "OK") {
//查詢?cè)敿?xì)地址信息
xpath = @"GeocodeResponse/result/formatted_address";
node = doc.SelectSingleNode(xpath);
address = node.InnerText.ToString();
//查詢地區(qū)信息
XmlNodeList nodeListAll = doc.SelectNodes("GeocodeResponse/result");

XmlNode idt = nodeListAll[0];
XmlNodeList idts = idt.SelectNodes("address_component[type='sublocality']");
//address_component[type='sublocality']表示篩選type='sublocality'的所有相關(guān)子節(jié)點(diǎn);
XmlNode idtst = idts[0];

string area = idtst.SelectSingleNode("short_name").InnerText;
address = address + "," + area;
}
}

address就是獲取到的具體地址信息和區(qū)域信息;

相關(guān)文章

最新評(píng)論