简体   繁体   中英

How to get Address name using GPS with wp7

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM