TileIssueViewController.m 1.65 KB
//
//  TileIssueViewController.m
//  TileIssue
//
//  Created by olivier on 4/8/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#include <unistd.h>
#import "TileIssueViewController.h"

@implementation TileIssueViewController

@synthesize mapView;

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView 
{
	CLLocationCoordinate2D latlong;	
	latlong.latitude = 43.61675;
	latlong.longitude = 6.97167;

	RMMapView *map = [[[RMMapView alloc] initWithFrame:CGRectMake(0.0, 0.0, [[UIScreen mainScreen] applicationFrame].size.width, [[UIScreen mainScreen] applicationFrame].size.height-79)] autorelease];
	[self setMapView:map];
	[self.mapView setZoom:18];
	self.view = mapView;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad 
{
    [NSThread detachNewThreadSelector: @selector(moveThread:) toTarget:self withObject:nil];
}

- (void)moveThread:(id)someLocation
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

	CLLocationCoordinate2D latlong;
	latlong.latitude = 43.61675;
	latlong.longitude = 6.97167;

	double s=1;
	for (int i=0; i<2; i++)
    {
		sleep(3);
		latlong.longitude += s*0.002;
		NSValue *vlocation= [NSValue value:&latlong withObjCType:@encode(CLLocationCoordinate2D)];
		[self performSelectorOnMainThread:@selector(moveToLatLon:) withObject:vlocation waitUntilDone:NO];
		s = -s;
	}

	[pool drain];
}

- (void)moveToLatLon:(NSValue *)vlocation
{
	CLLocationCoordinate2D location;
	[vlocation getValue:&location];
	[mapView setCenterCoordinate:location];
}

- (void)dealloc
{
	[mapView release];
    [super dealloc];
}

@end