Search code examples
xamldictionarywindows-phone-8geolocationstreet-address

Windows Phone 8: get current Address -Data (from your current location)


Im trying to implement a button which fills after click

  • Latitude
  • Longitude
  • Street
  • Streetnumber
  • Postalcode
  • City

myGeoposition.CivicAddress. gives me City and Postalcode

myGeoposition.Coordinate. gives me the Lati/Longitude

where do I get the rest?

I am using a Map-Control (not bing map!) from: Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps

 try
        {
            Geolocator geolocator = new Geolocator();
            geolocator.DesiredAccuracy = PositionAccuracy.Default;
            IAsyncOperation<Geoposition> locationTask = null;

            try
            {
                locationTask = geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(15));
                Geoposition myGeoposition = await locationTask;
                Geocoordinate myGeocoordinate = myGeoposition.Coordinate;

                GeoCoordinate myGeoCoordinate =
                CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

Solution

  • You can use the ReverseGeocodeQuery class to get information from a location:

    MapAddress address;
    ReverseGeocodeQuery query = new ReverseGeocodeQuery();
    query.GeoCoordinate = myGeoCoordinate;
    query.QueryCompleted += (s, e) =>
       {
            if (e.Error != null)
                return;
    
            address = e.Result[0].Information.Address;
        };
    query.QueryAsync();