c# - 如何使用带有wp7的GPS获取地址名称

标签 c# windows-phone-7

我可以使用 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结果的例子

Google Maps v3 geocoding server-side

Looking for a REST with JSON client library

关于c# - 如何使用带有wp7的GPS获取地址名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9294474/

相关文章:

windows-phone-7 - 可本地化的推送通知

javascript - Windows Phone Internet Explorer Mobile 7 浏览器是否支持触摸事件?

c# - 在 ItemsGrid View 中禁用鼠标滚轮滚动

c# - 在 Razor 中,如何打印带分隔符的循环?

c# - 如何在Windows Phone 7 Silverlight C#上删除列表<string>中的所有对象?

wpf - MVVM-Light 工具包 V4 Beta 中的 IDataService

windows-phone-7 - Windows Phone 7.1 开始屏幕磁贴边距是多少?

c# - 在结构中更改各种值(它们有多不可变?)

c# - 列名无效?时间:2019-03-17 标签:c#sql

c# - 检查表是否为空后插入数据