/samples/TileIssue/Classes/TileIssueViewController.m

http://github.com/route-me/route-me · Objective C · 87 lines · 49 code · 21 blank · 17 comment · 1 complexity · cd0fb6e5e7c321d7a9a030812fc725c9 MD5 · raw file

  1. //
  2. // TileIssueViewController.m
  3. // TileIssue
  4. //
  5. // Created by olivier on 4/8/09.
  6. // Copyright 2009 __MyCompanyName__. All rights reserved.
  7. //
  8. #include <unistd.h>
  9. #import "TileIssueViewController.h"
  10. @implementation TileIssueViewController
  11. @synthesize mapView;
  12. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  13. - (void)loadView
  14. {
  15. CLLocationCoordinate2D latlong;
  16. latlong.latitude = 43.61675;
  17. latlong.longitude = 6.97167;
  18. RMMapView *map = [[RMMapView alloc]initWithFrame:CGRectMake(0.0, 0.0, [[UIScreen mainScreen]applicationFrame].size.width, [[UIScreen mainScreen]applicationFrame].size.height-79) WithLocation:latlong];
  19. [self setMapView:map];
  20. [map release];
  21. [[[self mapView] contents]setZoom:18];
  22. self.view = mapView;
  23. }
  24. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  25. - (void)viewDidLoad
  26. {
  27. [NSThread detachNewThreadSelector: @selector(moveThread:) toTarget:self withObject:nil];
  28. }
  29. - (void)moveThread:(id)someLocation
  30. {
  31. NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ];
  32. CLLocationCoordinate2D latlong;
  33. latlong.latitude = 43.61675;
  34. latlong.longitude = 6.97167;
  35. double s=1;
  36. for(int i=0; i<2; i++){
  37. sleep(3);
  38. latlong.longitude+=s*0.002;
  39. NSValue *vlocation= [NSValue value:&latlong withObjCType:@encode(CLLocationCoordinate2D)];
  40. [self performSelectorOnMainThread:@selector(moveToLatLon:) withObject:vlocation waitUntilDone:NO];
  41. s=-s;
  42. }
  43. [pool drain];
  44. }
  45. -(void)moveToLatLon:(NSValue *)vlocation
  46. {
  47. CLLocationCoordinate2D location;
  48. [vlocation getValue:&location];
  49. [mapView moveToLatLong:location];
  50. }
  51. /*
  52. // Override to allow orientations other than the default portrait orientation.
  53. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  54. // Return YES for supported orientations
  55. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  56. }
  57. */
  58. - (void)didReceiveMemoryWarning {
  59. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  60. // Release anything that's not essential, such as cached data
  61. }
  62. - (void)dealloc {
  63. [mapView release];
  64. [super dealloc];
  65. }
  66. @end