//
//  LocationDisplayViewController.m
//  LocationDisplay
//
//  Created by Bill Dudney on 11/4/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//

#import "LocationDisplayViewController.h"

@implementation LocationDisplayViewController

@synthesize locationManager;
@synthesize longitudeTextField;
@synthesize latitudeTextField;

//START:code.location.viewDidLoad
- (void)viewDidLoad {
  [super viewDidLoad];
  self.locationManager = [[[CLLocationManager alloc] init] autorelease];
  self.locationManager.delegate = self;
  [self.locationManager startUpdatingLocation];
}
//END:code.location.viewDidLoad

//START:code.location.delegate.update
- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
  latitudeTextField.text = [NSString stringWithFormat:@"%3.5f",
                             newLocation.coordinate.latitude];
  longitudeTextField.text = [NSString stringWithFormat:@"%3.5f", 
                              newLocation.coordinate.longitude];
}
//END:code.location.delegate.update

@end
