我对几天前正常工作的 csome 代码有一点问题。我正在使用 Yahoos API 来获取 PostCodes 的经度和纬度,代码如下:
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;
正如我所说,代码在几天前运行良好,但现在对数和纬度总是返回为 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"
}
}
}
抱歉格式化 Stack 似乎不想把它格式化好!显然有一个逻辑和纬度返回。我确信这很简单,但我看不到它的爱或金钱,任何帮助将不胜感激。