【发布时间】:2012-03-06 20:37:05
【问题描述】:
我可以使用 GeoCoordinateWatcher 类在 Windows Phone 7 上获取当前 GPS 坐标,如 msdn 所示,我只能获取 Latitude 和 Longitude 值,但我想要获取该位置的地址。市场上有一个名为“我在哪里”的免费应用程序,它也显示地址名称,所以我认为它是可能的。
我该怎么做?
【问题讨论】:
标签: c# windows-phone-7
我可以使用 GeoCoordinateWatcher 类在 Windows Phone 7 上获取当前 GPS 坐标,如 msdn 所示,我只能获取 Latitude 和 Longitude 值,但我想要获取该位置的地址。市场上有一个名为“我在哪里”的免费应用程序,它也显示地址名称,所以我认为它是可能的。
我该怎么做?
【问题讨论】:
标签: c# windows-phone-7
您可以使用 Google 或 Yahoo API
http://maps.google.com/maps/geo?q=20.0,2.0&output=json&oe=utf8&sensor=true&key=你的钥匙
http://where.yahooapis.com/geocode?q=20.0,2.0&flags=J&gflags=R&appid=你的钥匙
这是来自 Google 的示例 json 响应
{
"name": "20.00,2.00",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [
{
"id": "p1",
"address": "Adrar des Ifôghas, Mali",
"AddressDetails": {
"Accuracy": 0,
"AddressLine": [
"Adrar des Ifôghas"
]
},
"ExtendedData": {
"LatLonBox": {
"north": 22.6604651,
"south": 17.2938071,
"east": 6.0979005,
"west": -2.0979005
}
},
"Point": {
"coordinates": [
2,
20,
0
]
}
}
]
}
编辑
您可以使用WebClient获取结果
WebClient w = new WebClient();
string page = w.DownloadString(url);
这里是解析 Json 结果的示例
【讨论】: