如何使用带有 wp7 的 GPS 获取地址名称 [英] How to get Address name using GPS with wp7

查看:16
本文介绍了如何使用带有 wp7 的 GPS 获取地址名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 GeoCoordinateWatcher 类在 Windows Phone 7 上获取当前 GPS 坐标,如 msdn,我只能得到LatitudeLongitude 值,但我想得到地址那个位置.市场上有一个名为我在哪里"的免费应用程序,它也显示地址名称,所以我认为这是可能的.
我该怎么做?

解决方案

您可以使用 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=您的密钥

这是来自 Google 的示例 json 响应

<代码>{"name": "20.00,2.00",地位": {代码":200,请求":地理编码"},地标":[{"id": "p1","address": "Adrar des Ifôghas, 马里",详细地址": {准确度":0,地址栏": ["Adrar des Ifôghas"]},扩展数据":{LatLonBox":{北":22.6604651,南":17.2938071,东":6.0979005,西":-2.0979005}},观点": {坐标":[2、20,0]}}]}

编辑

可以使用WebClient获取结果

WebClient w = new WebClient();字符串页面 = w.DownloadString(url);

这里是解析Json结果的示例

Google 地图 v3 地理编码服务器端

寻找带有 JSON 客户端库的 REST

I can get the current GPS coordinates on Windows Phone 7 using GeoCoordinateWatcher class as shown on msdn, I can only get Latitude and Longitude values, but I want to get Address of that location. There is a free application on market named "Where Am I" it shows Address names too, so I think its possible.
How I do that?

解决方案

You can use Google or Yahoo APIs

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

Here is a sample json response from Google

{
    "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
                ]
            }
        }
    ]
}

EDIT

You can use WebClient to get the result

WebClient w = new WebClient();
string page = w.DownloadString(url);

Here are the samples to parse the Json result

Google Maps v3 geocoding server-side

Looking for a REST with JSON client library

这篇关于如何使用带有 wp7 的 GPS 获取地址名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆