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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-17-2009, 08:10 PM   #1 (permalink)
New Member
 
Join Date: May 2009
Posts: 2
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 08:16 PM. Reason: incomplete info
lionkingden is offline   Reply With Quote
Old 05-18-2009, 11:04 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: San Diego, CA
Posts: 406
Default

You haven't supplied a delegate method for the CLLocationManager to call. Since the delegate method is optional, CLLocationManager just goes merrily on it's way.

The code starting with // Use the timestamp... needs to be moved to your delegate.
jtara is offline   Reply With Quote
Reply

Bookmarks

Tags
cllocationmanager, gps, time stamp

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 316
19 members and 297 guests
@sandris, ADY, dacapo, Dani77, djohnson, dre, HDshot, HemiMG, JasonR, MarkC, mer10, nibeck, prchn4christ, ryandb2, spiderguy84, timle8n1, tomtom100, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:05 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0