public String [] TestLocation(String address)
{
String[] location = new String[2];
var url = String.Format("http://maps.google.com/maps/api/geocode/json?sensor=false&address={0}", address);
string result = String.Empty;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
using (var response = request.GetResponse())
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
//Json格式: 請參考http://code.google.com/intl/zh-TW/apis/maps/documentation/geocoding/
result = sr.ReadToEnd();
Dictionary
result = "";
foreach (var item in back)
{
if (item.Key == "results")
{
String temp = item.Value.ToString();
temp = temp.Substring(0, temp.Length-1);
temp = temp.Substring(1, temp.Length-1);
temp.ToString();
Dictionary
foreach (var item2 in back2)
{
if (item2.Key == "geometry")
{
temp = item2.Value.ToString();
Dictionary
foreach (var item3 in back3)
{
if (item3.Key == "location")
{
temp = item3.Value.ToString();
Dictionary
foreach (var item4 in back4)
{
if (item4.Key == "lat")
{
location[0] = item4.Value.ToString();
}
if (item4.Key == "lng")
{
location[1] = item4.Value.ToString();
}
}
}
}
}
}
}
}
}
return location;
}
沒有留言:
張貼留言