/samples/MapTestbed/Classes/FlipsideViewController.m

http://github.com/route-me/route-me · Objective C · 71 lines · 45 code · 19 blank · 7 comment · 0 complexity · cdec9f483a2bda4084becb9d5a6dc504 MD5 · raw file

  1. //
  2. // FlipsideViewController.m
  3. // MapTestbed : Diagnostic map
  4. //
  5. #import "FlipsideViewController.h"
  6. #import "MapTestbedAppDelegate.h"
  7. @implementation FlipsideViewController
  8. @synthesize centerLatitude;
  9. @synthesize centerLongitude;
  10. @synthesize zoomLevel;
  11. @synthesize minZoom;
  12. @synthesize maxZoom;
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. contents = [(MapTestbedAppDelegate *)[[UIApplication sharedApplication] delegate] mapContents];
  16. self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
  17. }
  18. // Override to allow orientations other than the default portrait orientation.
  19. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  20. // Return YES for supported orientations
  21. return YES;
  22. }
  23. - (void)didReceiveMemoryWarning {
  24. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  25. // Release anything that's not essential, such as cached data
  26. }
  27. - (void)viewDidAppear:(BOOL)animated {
  28. CLLocationCoordinate2D mapCenter = [contents mapCenter];
  29. [centerLatitude setText:[NSString stringWithFormat:@"%f", mapCenter.latitude]];
  30. [centerLongitude setText:[NSString stringWithFormat:@"%f", mapCenter.longitude]];
  31. [zoomLevel setText:[NSString stringWithFormat:@"%f", contents.zoom]];
  32. [maxZoom setText:[NSString stringWithFormat:@"%f", contents.maxZoom]];
  33. [minZoom setText:[NSString stringWithFormat:@"%f", contents.minZoom]];
  34. }
  35. - (void)viewWillDisappear:(BOOL)animated {
  36. CLLocationCoordinate2D newMapCenter;
  37. newMapCenter.latitude = [[centerLatitude text] doubleValue];
  38. newMapCenter.longitude = [[centerLongitude text] doubleValue];
  39. [contents moveToLatLong:newMapCenter];
  40. [contents setZoom:[[zoomLevel text] floatValue]];
  41. [contents setMaxZoom:[[maxZoom text] floatValue]];
  42. [contents setMinZoom:[[minZoom text] floatValue]];
  43. }
  44. - (void)dealloc {
  45. self.centerLatitude = nil;
  46. self.centerLongitude = nil;
  47. self.zoomLevel = nil;
  48. self.minZoom = nil;
  49. self.maxZoom = nil;
  50. [super dealloc];
  51. }
  52. @end