如何在wp7中使用GPS获取地址名称

3

我可以使用GeoCoordinateWatcher类在Windows Phone 7上获取当前GPS坐标,如msdn所示,但我只能获得纬度经度值,但我想要获得该位置的地址。市场上有一个名为“Where Am I”的免费应用程序,它也显示地址名称,因此我认为这是可能的。
我该怎么做?

1个回答

2
你可以使用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结果的示例:

Google Maps v3地理编码服务器端

寻找一个带有JSON客户端库的REST


我如何在C#应用程序中使用那些API? - Mustafa Ekici

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接