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 6672371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:30:01+00:00 2026-05-26T03:30:01+00:00

I am working an iPhone app which is using CLLocationManager. When a user goes

  • 0

I am working an iPhone app which is using CLLocationManager. When a user goes for a run, it shows the run path on a mapView. I am drawing the running path on mapView using following code:

 double leastDistanceToRecord = 0.0000905;

 - (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if (newLocation.horizontalAccuracy >= 0) {
    if (!runoPath)
    {
        NSLog(@"in !runoPath if");
        // This is the first time we're getting a location update, so create
        // the RunoPath and add it to the map.
        runoPath = [[RunoPath alloc] initWithCenterCoordinate:newLocation.coordinate];
        [map addOverlay:runoPath];

        self.currentRunData = [[RunData alloc] init];

        [currentRunData startPointLocation:newLocation];    

        // On the first location update, zoom map to user location
        MKCoordinateRegion region = 
        MKCoordinateRegionMakeWithDistance(newLocation.coordinate, 1000, 1000);
        [map setRegion:region animated: NO];


    }
    else
    {
        // This is a subsequent location update.
        // If the runoPath MKOverlay model object determines that the current location has moved
        // far enough from the previous location, use the returned updateRect to redraw just
        // the changed area.

        double latitudeChange = fabs(newLocation.coordinate.latitude - oldLocation.coordinate.latitude);
        double longitudeChange = fabs(newLocation.coordinate.latitude - oldLocation.coordinate.longitude);
        if (latitudeChange > leastDistanceToRecord || longitudeChange > leastDistanceToRecord) {
            MKMapRect updateRect = [runoPath addCoordinate:newLocation.coordinate];
            if (!MKMapRectIsNull(updateRect))
            {
                // There is a non null update rect.
                // Compute the currently visible map zoom scale
                MKZoomScale currentZoomScale = map.bounds.size.width / map.visibleMapRect.size.width;
                // Find out the line width at this zoom scale and outset the updateRect by that amount
                CGFloat lineWidth = MKRoadWidthAtZoomScale(currentZoomScale);
                updateRect = MKMapRectInset(updateRect, -lineWidth, -lineWidth);
                // Ask the overlay view to update just the changed area.
                [runoPathView setNeedsDisplayInMapRect:updateRect];
            }
        //  [currentRunData updateLocation:oldLocation toNewLocation: newLocation];         
        }
        [currentRunData updateLocation:oldLocation toNewLocation: newLocation]; 

//  }
}
 }
 }

The problem is that when I start a run, I get some extra points and then because of those points I get an extraneous line on mapView that does not reflect the actual run. It even happens when I install the app on my iPhone and run it for the first time. I don’t know why it’s adding those extra points. Can anyone help me with that? Thanks in advance.

  • 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-26T03:30:02+00:00Added an answer on May 26, 2026 at 3:30 am

    The first location you get is usually a cached location and is old. You can check the age of the location and if it is old (>60 seconds or whatever) then ignore that location update. See this answer here.

    —EDIT— If you are still having problems, put this code in didUpdateToLocation: and show us the actual output from NSLog (you can edit your question and add the output):

    NSTimeInterval age = -[newLocation.timestamp timeIntervalSinceNow]; 
    NSLog(@"age: %0.3f sec, lat=%0.2f, lon=%0.2f, hAcc=%1.0f", 
          age, newLocation.coordinate.latitude, newLocation.coordinate.longitude,
          newLocation.horizontalAccuracy); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an iPhone app which involves using json-framework.I am getting array
I'm working on an iPhone app using objective C. I've got class A, which
I am working on an iPhone app which is using an external library for
I'm working on an iPhone app that offers the user the opportunity to send
In an iPhone app I'm working on, the user needs to enter some configuration
Im working on an iphone web app using JQTouch , im just wondering what
I am working on one iPhone app which needs latitude and longitude from address.
I'm working on a iPhone app which has a pretty large UITableView with data
I'm working on an iPhone app using the 3.1.3 SDK, my app finds the
I have an iPhone app which submits user entered data to a SQL database.

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.