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];