0
幾天前,我正在使用csome代碼正常工作。我使用雅虎的API來獲取郵政編碼logitude和緯度的代碼如下:在C#.NET中使用Yahoo API的GeoCode
string url = string.Format("http://where.yahooapis.com/geocode?flags=J&appid=xxxx&location={0}", postcode);
decimal latitude = 0;
decimal longitude = 0;
Dictionary<string, decimal> geoCode = new Dictionary<string, decimal>();
dynamic yahooResults = new Uri(url).GetDynamicJsonObject();
foreach (var result in yahooResults.ResultSet.Results)
{
latitude = (decimal)result.latitude;
longitude = (decimal)result.longitude;
}
geoCode.Add("latitude", latitude);
geoCode.Add("longitude", longitude);
return geoCode;
正如我所說的代碼是前幾天做工精細但總是返回現在logitude和緯度爲0。我包括從雅虎迴應如下:
{
"@lang": "en-US",
"ResultSet": {
"@version": "2.0",
"@lang": "en-US",
"Error": "0",
"ErrorMessage": "No error",
"Locale": "en-US",
"Found": "1",
"Quality": "60",
"Result": {
"quality": "60",
"latitude": "51.62071",
"longitude": "-0.23616",
"offsetlat": "51.620708",
"offsetlon": "-0.23616",
"radius": "4200",
"name": "",
"line1": "",
"line2": "London",
"line3": "NW7",
"line4": "United Kingdom",
"house": "",
"street": "",
"xstreet": "",
"unittype": "",
"unit": "",
"postal": "NW7",
"neighborhood": "",
"city": "London",
"county": "Greater London",
"state": "England",
"country": "United Kingdom",
"countrycode": "GB",
"statecode": "ENG",
"countycode": "LND",
"uzip": "NW7",
"hash": "",
"woeid": "26787971",
"woetype": "11"
}
}
}
對不起,格式化堆棧似乎不想格式化好!顯然有返回的緯度和緯度。我確信這是簡單的,但我不能看到它的愛或金錢,任何幫助將不勝感激。
偉大的東西LB工作的一種享受! –
看起來他們改回來了...... – marcog