views:

67

answers:

3

So, I've created a CLLocationManager, called it to start updating, set mapView.showsUserLocation to YES, and returned nil for the userLocation annotation. Here are some snippets from my code in my UIMapViewController:

- (void)viewDidLoad
{
     CLLocationManager *locationManager = [[CLLocationManager alloc] init];
     [locationManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{ 
 CLLocationCoordinate2D userCoordinate = locationManager.location.coordinate;
 [map setCenterCoordinate:userCoordinate animated:YES];
 [map setShowsUserLocation:YES];  
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{

 MKAnnotationView *mapIconView = (MKAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:@"mapIconView"];

 // Don't mess with the user location annotation
     if (annotation == mapView.userLocation)
              return nil;

    // etc.
}     

This all seems pretty straightforward. Everything works fine--the map zooms to my location as it should, and I've confirmed that all the methods are called as expected--but no blue dot. Can't get the blue dot for the life of me, no matter where or how many times I say

mapView.setUserLocation = YES;

What am I missing here?

A: 

When I do this, rather than checking annotation like you have, I do something along the lines of:

if([annotation class] == MKUserLocation.class) {
    return nil;
}
dc
Thank you, but that doesn't seem to change anything. Still no dot. I can step through the code and watch the { return nil; } get called, so I don't think the problem is there.
Aeonaut
A: 

its mapView.showUserLocation = YES;

You seem to have used the wrong statement 'set' instead of 'show'.

And FYI u dont have to messup with location manager just to get the userlocation. Corelocation automatically gets fired when you set the mapview.showUserLoction = YES and load the map.

Hope it helps :)

swapnil
A: 

I also have this issue and i'm not able to get the blue dot even though I have set the showUserLocation flag to YES and implemented the viewForAnnotation method ¿any thoughts?

Pacu