Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    298

    Fast way to get User's Location (and city name)

    Hello,

    I'd like to know if there is a faster way to get users' location I'm using the code below, and I find it a little slow about 2-5 seconds to get a location
    Code:
            public async Task<Geoposition> UserLocation()
            {
                Geolocator geolocator = new Geolocator();
                geolocator.DesiredAccuracyInMeters = 50;
    
                try
                {
                    Geoposition geoposition = await geolocator.GetGeopositionAsync(
                        maximumAge: TimeSpan.FromMinutes(5),
                        timeout: TimeSpan.FromSeconds(10)
                        );
                    return geoposition;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
    
            }
    And also is there a way to get the location's city name in offline mode, ("Microsoft.Phone.Maps.Services" needs internet connexion.)

    Thank you,
    Last edited by Loukt; 2013-02-26 at 04:47. Reason: Corrected a code error

  2. #2
    Regular Contributor
    Join Date
    Jul 2012
    Posts
    88

    Re: Fast way to get User's Location (and city name)

    Hello,

    The geolocator used cellular or GPS triangulation to get the location, the more accurate it is, the longer it will take to get a fix on the location, 2-5seconds are "acceptable" I think.
    For the location city name , you can use the ReverseGeocodeQuery class, this works offline.

    Hope this helps,

  3. #3
    Regular Contributor
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    298

    Re: Fast way to get User's Location (and city name)

    Quote Originally Posted by WPMorocco View Post
    Hello,
    The geolocator used cellular or GPS triangulation to get the location, the more accurate it is, the longer it will take to get a fix on the location, 2-5seconds are "acceptable" I think.
    So if I leave this parameter by default, geolocator.DesiredAccuracyInMeters = 50; It would go faster ?
    (can I control which way to get Location (Gps/cellular/Wifi) ?)

    Quote Originally Posted by WPMorocco View Post
    For the location city name , you can use the ReverseGeocodeQuery class, this works offline.
    Oh sweet, I thought it needed internet connexion like for downloading a set of POIs,

    Thank you WPMorocco,

    Edit : I had a little issue getting User's Location in Application launch (like on foursquare), so I put my method in the constructor of the first page, then in the "OnNavigatedTo", but in both cases the method "GetGeopositionAsync" just hanged there without retrieving the location (more than 20 sec).
    Putting it in the page Loaded event solved the problem.
    So the app needs to be loaded before trying to retrieve User's Location.
    Last edited by Loukt; 2013-02-28 at 00:22.

Similar Threads

  1. Replies: 2
    Last Post: 2011-05-06, 13:50
  2. Fast Tapping in 5800 -> user 130
    By Kaz32 in forum Symbian
    Replies: 3
    Last Post: 2009-12-07, 11:10
  3. City and Country - User Profile
    By antonio5982 in forum Mobile Java General
    Replies: 7
    Last Post: 2009-02-13, 13:23
  4. Show location/City information while application launch.
    By gangaraju in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2008-09-19, 12:24

Posting Permissions

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