我可以使用 GeoCoordinateWatcher 类获取 Windows Phone 7 上的当前 GPS 坐标,如 msdn 所示,我只能获取纬度和经度值,但我想获取该位置的地址。市场上有一个名为“我在哪里”的免费应用程序,它也显示地址名称,所以我认为它是可能的。
我该怎么做?
最佳答案
您可以使用 Google 或 Yahoo API
http://maps.google.com/maps/geo?q=20.0,2.0&output=json&oe=utf8&sensor=true&key=YOURKEY
http://where.yahooapis.com/geocode?q=20.0,2.0&flags=J&gflags=R&appid=YOURKEY
这是来自 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结果的例子
关于c# - 如何使用带有wp7的GPS获取地址名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9294474/