Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 494171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:28:22+00:00 2026-05-13T05:28:22+00:00

I am using location manager in my application and i’m getting inaccurate location.I’m using

  • 0

I am using location manager in my application and i’m getting inaccurate location.I’m using below code for getting location

locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;

and in didupdatetolocation method i’m using this code.

LatitudeData = [[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.latitude];
    LongitudeData = [[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude];
    [UIApplication sharedApplication].networkActivityIndicatorVisible=NO;
    [self insertNewLocationInDataBase];

do i need to set distancefilter? how do i get the accurate location? i want to get accurate location then will insert location in database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:28:22+00:00Added an answer on May 13, 2026 at 5:28 am

    Getting a good result from Core Location in a reasonable amount of time takes some careful finagling.

    The issue is that once you start updating, didUpdateToLocation will fire several times. Each time it fires, the location should be more accurate. However, you do not know how many times it will fire, nor do you know how fast a lock to your requested accuracy will occur (if it ever does). As per the documentation, additional events are generated if the minimum threshold distance (as specified by the distanceFilter property) is exceeded or a more accurate location value is determined. Changing the distanceFilter won’t give you a better location (unless, of course, you’re interested in precise movements).

    There are some common setups to help make this simpler, but you’ll probably want to fiddle with this depending upon the specific heuristics you desire.

    • Set a timer after you send startUpdating to call a selector (can be as simple as performSelector:afterDelay:). Set your delay to the maximum amount of time you’re willing to wait for a reasonable approximation. In that selector’s method, I would check to make sure that the location is accurate enough for placement in the database, and insert it. If it isn’t, I’d alert the user.
    • In didUpdateToLocation, immediately discard any locations that are too old. The LocationManager will often first return the cached value of its location — and it may be very old.
    • In didUpdateToLocation, simply save the latest result to an instance variable if it’s not to your desired accuracy.
    • In didUpdateToLocation, if the new location is accurate enough, cancel that perform selector after delay, and instead call it immediately.

    That’s just a rough sketch, but it’s a pretty versatile setup that you can easily extend to have the functionality you desire.

    Here’s the basic outline of how this might work. This is a paired down snippet from one of my view controllers to just show the basics of the relevant parts:

    - (void)viewWillAppear:(BOOL)animated {
        [self.locationManager startUpdatingLocation];
        [self performSelector:@selector(finishUpdating) withObject:nil afterDelay:10.0];
        [super viewWillAppear:animated];
    }
    
    - (void) locationManager:(CLLocationManager *)manager
         didUpdateToLocation:(CLLocation *)newLocation
                fromLocation:(CLLocation *)oldLocation {
        /* Refuse updates more than a minute old */
        if (abs([newLocation.timestamp timeIntervalSinceNow]) > 60.0) {
            return;
        }
        /* Save the new location to an instance variable */
        self.lastUpdatedLocation = newLocation;
    
        /* If it's accurate enough, cancel the timer */
        if (newLocation.horizontalAccuracy < 20.0) {
            [NSObject cancelPreviousPerformRequestsWithTarget:self 
                                                     selector:@selector(finishUpdating) 
                                                       object:nil]
            /* And fire it manually instead */
            [self finishUpdating];
        }
    }
    
    - (void) finishUpdating {
        /* Check the accuracy of self.lastUpdatedLocation, and either
         * save it or alert the user that it's not accurate enough */
        [self.locationManager stopUpdatingLocation];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using a Location Manager to get a Location object containing Latitude and Longitude,
I'm trying to get my location using it like this: LocationManager myLocationManager = (LocationManager)
I am developing an application in which i am using location service. Basically that
After removing hash from URL using window.location.hash='' page getting reloaded in firefox. EDIT Example:
I am creating an application which tracks the users location using GPS, stores the
I've been trying to code a simple screenshot application using rococoa (java to osx
I have application using Android 2.1 which utilize LocationManager to get the altitude. But
I have developed an application to find the user's location using GPS. In this
it is possible to reload a div or a table using location.reload(); ? after
I am using Drupal Location module in CCK to retreive longitude & latitude based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.