Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-01-2008, 09:07 PM   #1 (permalink)
varchar
Registered Member
 
Join Date: Aug 2008
Posts: 100
varchar is on a distinguished road
Default CLLocationManager - not updated frequently

Hi,

I am successfully using the CLLocationManager (and associated objects) to interact with the GPS. It seems to work "ok", but the main problem I am having is that it does not seem to be updating properly.

For example:

I get GPS coordinates at one location. Then I walk about 1 block down and the coordinates remain the same (yes I am looking after the 3rd decimal point)

Interesting enough, when I use the iphone maps app, it seems to update more frequently and accurately... Any suggestions?

Below is my code (keep in mind I modified most of it from various sources, including the SDK examples).




// Called when the location is updated
- (void)locationManagerCLLocationManager *)manager
didUpdateToLocationCLLocation *)newLocation
fromLocationCLLocation *)oldLocation
{


NSMutableString *lastTimeUpdated = [[[NSMutableString alloc] init] autorelease];
NSMutableString *currentLatitude = [[[NSMutableString alloc] init] autorelease];
NSMutableString *currentLatitudeDirection = [[[NSMutableString alloc] init] autorelease];

NSMutableString *currentLongitude = [[[NSMutableString alloc] init] autorelease];
NSMutableString *currentLongitudeDirection = [[[NSMutableString alloc] init] autorelease];

// Timestamp
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[lastTimeUpdated appendFormat:@"%@\n\n", [dateFormatter stringFromDate:newLocation.timestamp]];

// Horizontal coordinates
if (signbit(newLocation.horizontalAccuracy))
{
// Negative accuracy means an invalid or unavailable measurement
[currentLatitude appendString:LocStr(@"LatLongUnavailable")];
}
else
{
// CoreLocation returns positive for North & East, negative for South & West

//currentLatitude = [NSString stringWithFormat:@"%lf",fabs(newLocation.coordinat e.latitude)];
currentLatitude = [NSString stringWithFormat:@"%lf",newLocation.coordinate.lat itude];
currentLatitudeDirection = signbit(newLocation.coordinate.latitude) ? LocStr(@"South") : LocStr(@"North");

currentLongitude = [NSString stringWithFormat:@"%lf",fabs(newLocation.coordinat e.longitude)];
currentLongitude = [NSString stringWithFormat:@"%lf",newLocation.coordinate.lon gitude];

currentLongitudeDirection = signbit(newLocation.coordinate.latitude) ? LocStr(@"West") : LocStr(@"East");


// [update appendString:@"\n"];
//[update appendFormat:LocStr(@"MeterAccuracyFormat"), newLocation.horizontalAccuracy];
}

// Send the update to our delegate
[self.delegate newLocationUpdate: lastTimeUpdated: currentLatitude: currentLatitudeDirection: currentLongitude: currentLongitudeDirection];
}



-(void)newLocationUpdate: (NSString *)lastTimeUpdated: (NSString *) currentLatitude: (NSString *) currentLatitudeDirection: (NSString *) currentLongitudeNSString *) currentLongitudeDirection {


[activityIndicator startAnimating];

myCurrentLatitude= currentLatitude;
myCurrentLongitude = currentLongitude;


[[MyCLController sharedInstance].locationManager stopUpdatingLocation];


}
varchar is offline   Reply With Quote
 

» Advertisements
» Online Users: 574
14 members and 560 guests
daunmi, givensur, Hassasin, headkaze, iconomania, iekei, Joseph262, kasumar, lzwasyc, mariano_donati, sunlite, Thompson22, w0rldsell3r, yvonneolivia
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,443
Threads: 94,028
Posts: 402,599
Top Poster: BrianSlick (7,978)
Welcome to our newest member, Joseph262
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:16 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.