×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2013
    Location
    Pune, India
    Posts
    3

    Question Using ReverseGeocodeQuery to show current user location

    Hello,

    I am developing a simple app for Windows Phone 8 to get current user's location. I want to get location information of the user that will be understood by other people e.g. Suburb location in a city. For that purpose I am using GeoLocator to get GeoPosition. Then I am using this GeoPosition in ReverseGeocodeQuery to get location results. Here is the simplified code what I am trying to do -

    Code:
    private async void GetLocation()
            {
                m_geolocator = new Geolocator();
                m_geolocator.DesiredAccuracyInMeters = 50;
    
                Geoposition geoposition = await m_geolocator.GetGeopositionAsync(
                    maximumAge: TimeSpan.FromMinutes(5),
                    timeout: TimeSpan.FromSeconds(10)
                    );
             
                string str = geoposition.Coordinate.Latitude.ToString("0.00");
    
                m_revGeoQuery = new ReverseGeocodeQuery();
                m_revGeoQuery.GeoCoordinate = CoordinateConverter.ConvertGeocoordinate(geoposition.Coordinate);
                m_revGeoQuery.QueryCompleted += m_revGeoQuery_QueryCompleted;
                m_revGeoQuery.QueryAsync();
            }
    
            private void m_revGeoQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
            {
                Debug.WriteLine("Geo query, error: " + e.Error);
                Debug.WriteLine("Geo query, cancelled: " + e.Cancelled);
                Debug.WriteLine("Geo query, cancelled: " + e.UserState.ToString());
                Debug.WriteLine("Geo query, Result.Count(): " + e.Result.Count());
    
    
                if (e.Result.Count() > 0)
                {
                    string showString = e.Result[0].Information.Name;
                    showString = showString + "\nAddress: ";
                    showString = showString + "\n" + e.Result[0].Information.Address.HouseNumber + " " + e.Result[0].Information.Address.Street;
                    showString = showString + "\n" + e.Result[0].Information.Address.PostalCode + " " + e.Result[0].Information.Address.City;
                    showString = showString + "\n" + e.Result[0].Information.Address.Country + " " + e.Result[0].Information.Address.CountryCode;
                    showString = showString + "\nDescription: ";
                    showString = showString + "\n" + e.Result[0].Information.Description.ToString();
    
                    txtLocation.Text = showString;
                }     
            }

    Here the issue that I am facing is that in e.Results.Count is never greater than 0. It does not have any error, but it does not show any results information as well. I tried running this code in emulator. I do not have a device so not sure if it is an emulator issue.

  2. #2
    Regular Contributor
    Join Date
    Aug 2012
    Location
    Rhine Valley
    Posts
    93

    Re: Using ReverseGeocodeQuery to show current user location

    Hi,

    I tried your code and - with changing one line - it worked.

    Code:
            m_revGeoQuery.GeoCoordinate = new System.Device.Location.GeoCoordinate(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
    Here's the result from the emulator:


    Thomas
    - <a href="http://www.dvlup.com/influencer/invite">Visit DVLUP and earn rewards</a>

  3. #3
    Registered User
    Join Date
    Feb 2013
    Location
    Pune, India
    Posts
    3

    Re: Using ReverseGeocodeQuery to show current user location

    Thanks influencer for your code. I tried your suggestion, but still it now worked for me.

    I am wondering if I am doing something wrong while using emulator. I using Location tab of emulator and using search text box to locate my city and then added push pins at one or two locations.



    In my code while debugging I can see same Longitude and Latitude values as seen in screenshot. But reverse GeoQuery count is not greater than 0. Could this be limitation of here maps that it is not providing me reverse geocoding info here in India OR am I doing something wrong?

Similar Threads

  1. Localized ReverseGeocodeQuery
    By nesher_hh in forum Windows Phone General
    Replies: 9
    Last Post: 2012-11-17, 17:37
  2. Get My Current Location Lat, lon
    By HadiDelphi in forum [Archived] Qt Mobility Project
    Replies: 4
    Last Post: 2011-07-06, 06:57
  3. Show user location in OVI maps from the J2me application
    By ajitkumar26 in forum Mobile Java General
    Replies: 7
    Last Post: 2011-06-13, 09:12
  4. How to show current time?
    By komomo in forum Mobile Java General
    Replies: 10
    Last Post: 2010-07-15, 04:37
  5. How to get current GPS location
    By videoFx in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2009-04-07, 06:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×