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 05-17-2009, 07:10 PM   #1 (permalink)
lionkingden
New Member
 
Join Date: May 2009
Posts: 2
lionkingden is on a distinguished road
Unhappy GPS location timestamp issue

isn't this code enough to get the current location using the locationManager. I try to do it checking the timestamp and using a loop

The reason i ask is because i am getting 0000.0 as ltitude and longitudes and cannot figure out why

Code:
// initialization of CLLocationManager

CLLocationManager *locationManager = [[CLLocationManager alloc] init];

locationManager.delegate = self;
locationManager.distanceFilter = 1000; // 1 kilometer
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
[locationManager startUpdatingLocation];

//use the timestamp to get the latest location

NSDate* eventDate = locationManager.location.timestamp;
NSTimeInterval howRecent;
do{

howRecent = [eventDate timeIntervalSinceNow];
}
while(abs(howRecent) > 5.0);

//stop gps after getting the recent location

[locationManager stopUpdatingLocation];

float lat= locationManager.location.coordinate.latitude+0.0;
float lon= locationManager.location.coordinate.latitude+0.0;

//create the HTML for the webpage

NSString *HTMLData = [NSString stringWithFormat: @"latitude %f longitude %f at %c",lat, lon, howRecent];

[webView loadHTMLString:HTMLData baseURL:nil];

Last edited by lionkingden; 05-17-2009 at 07:16 PM. Reason: incomplete info
lionkingden is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,638
Threads: 94,102
Posts: 402,823
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Studder
Powered by vBadvanced CMPS v3.1.0

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