Not zooming in


#1

I have implemented the fix from the sticky above, but the view is still not zooming for me :frowning: Here’s the whereamiAppDelegate.m

[code]#import “WhereamiAppDelegate.h”
#import “MapPoint.h”

@implementation WhereamiAppDelegate

@synthesize window=_window;

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@“Could not find location: %@”, error);
}

-(void)foundLocation {
[locationTitleField setText:@""];
[activityIndicator stopAnimating];
[locationTitleField setHidden:NO];
[locationManager stopUpdatingLocation];
}

-(void)findLocation {

}

-(BOOL)textFieldShouldReturn:(UITextField *)tf {
[self findLocation];
[tf resignFirstResponder];
return YES;
}

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    //Create location manager object
    locationManager = [[CLLocationManager alloc] init];

    //Make this instance of whereamiAppDelegate the delegate it will send its messages to our whereamiAppdDelegate
    [locationManager setDelegate:self];

    //We want all results from the location manager
    [locationManager setDistanceFilter:kCLDistanceFilterNone];

    //And we want it to be as accurate as possible
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

    //Tell our manager to start looking for its location immediately
    //[locationManager startUpdatingLocation];
    [mapView setShowsUserLocation:YES];

    // Override point for customization after application launch.
    [self.window makeKeyAndVisible];
    return YES;
    }

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"%@", newLocation);

//how manu seconds ago was this new location created
NSTimeInterval t = [[newLocation timestamp] timeIntervalSinceNow];

//if this location was made more then 3 minutes ago, ignore it
if(t < 180){
    //this is cached data, you don't want it, keep looking
    return;
}

MapPoint *mp = [[MapPoint alloc] initWithCoordinate:[newLocation coordinate] title:[locationTitleField text]];
[mapView addAnnotation:mp];
[mp release];

}

-(void)mapView:(MKMapView *)worldView didUpdateUserLocation:(MKUserLocation *)userLocation {
CLLocationCoordinate2D loc = [userLocation coordinate];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250);
[worldView setRegion:region animated:YES];
}

  • (void)applicationWillResignActive:(UIApplication )application
    {
    /

    Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    */
    }

  • (void)applicationDidEnterBackground:(UIApplication )application
    {
    /

    Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    */
    }

  • (void)applicationWillEnterForeground:(UIApplication )application
    {
    /

    Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    */
    }

  • (void)applicationDidBecomeActive:(UIApplication )application
    {
    /

    Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    */
    }

  • (void)applicationWillTerminate:(UIApplication )application
    {
    /

    Called when the application is about to terminate.
    Save data if appropriate.
    See also applicationDidEnterBackground:.
    */
    }

  • (void)dealloc
    {
    [locationManager setDelegate:nil];
    [_window release];
    [super dealloc];
    }

@end
[/code]

I’m not getting any warnings/errors


#2

Place a breakpoint inside your mapView:didUpdateUserLocation: method to see if you’re even receiving the callback. If you’re not, re-check your .xib file to make sure that you’ve properly set your App Delegate to be the delegate of worldView (the MKMapView).