GPS incorrect, compass GPS correct.. Confused.

Discussion in 'iOS Programming' started by R.R.Mac, Jul 17, 2011.

  1. macrumors regular


    Sep 16, 2006
    Guildford, England

    I've made a sailing app which records lots of data. One thing it records is GPS location. I downloaded Locate Me from the apple website as it was under one of the recommended apps. I've also got an app from 'beginning iPhone development'. Both their apps and mine are all giving a GPS location which is incorrect. I've set the accuracy to best and then to 10 metres with no difference in result. However, when I go into the compass and look at the GPS location there, it is almost exactly correct.

    This is a navigation app (tried using the navigation accuracy too) and I need the GPS location to be almost spot on. Does anyone know how to do this? The compass app apple provides is perfect, does anyone know what I need to do? I've based my GPS code on that of Locate Me.

  2. Moderator emeritus


    Jul 24, 2002
    Are you just taking one (the first) location from Location Services? Or do you register to keep getting updates? As they location gets much more accurate over time so you need to keep getting updates.

    To get any meaningful help you should post all of your location code with some explanation.
  3. thread starter macrumors regular


    Sep 16, 2006
    Guildford, England

    I am just taking the first location but the Locate Me app and the app from the book I bought also takes it constantly and yields the same results. My code is below.

    What I believe, is that as soon as it finds the location to the accuracy given, it continues with the code and so I should only have to call it once. I could change this but i've basically stolen the code from Locate Me and WhereAmI from the book I bought and they all yield the same results regardless of how long it's been calling for.The compass app gets the accuracy right the first time.

    Sorry it's taken so long to reply, i'm actually currently on the boat this app was meant to be used for and so I don't always have internet.

        if(listOfObjects == nil){  //listOfObjects is an Array
            [self createArrayList];
        if(locationManager == nil){
            gpsObject = [[GPSObject alloc]init];  //this is a GPS object holding coordinates etc
            self.locationManager = [[CLLocationManager alloc] init];
            locationManager.delegate = self;
            locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
            locationManager.distanceFilter = kCLDistanceFilterNone;
            [locationManager startUpdatingLocation];
            gpsObject = [[GPSObject alloc]init];
            [locationManager startUpdatingLocation];
    - (void)locationManager:(CLLocationManager *)manager
        didUpdateToLocation:(CLLocation *)newLocation
               fromLocation:(CLLocation *)oldLocation {
        //    NSLog(@"Updating Location");
        if (startingPoint == nil){
            self.startingPoint = newLocation;
        NSDate *dateNow = [[NSDate alloc]init];
        gpsObject.startDate = dateNow;
        NSString *latitudeStr = [[NSString alloc] initWithFormat:@"%g\u00B0",
        gpsObject.latitude = latitudeStr;
        [latitudeStr release];
        NSString *horizontalAccuracyString = [[NSString alloc]
        [horizontalAccuracyString release];
        NSString *longitudeStr = [[NSString alloc] initWithFormat:@"%g\u00B0",
        gpsObject.longitude = longitudeStr;
        NSLog(@"Longitude is: %@", longitudeStr);
        [longitudeStr release];
        [listOfObjects addObject:gpsObject]; //adds the object to the list of objects
        [gpsObject release];
        gpsObject = nil;
        [locationManager stopUpdatingLocation]; //stops updating the location

Share This Page