Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showsUserLocation returns pin instead of blue dot in iPhone simulator

This is my -mapView:viewForAnnotation method which drops pins when i create annotation views. But when i set mapView.showsUserLocation = YES; in -viewDidLoad, i get a pin dropped on Infinite Loop (expected - in simulator) and not the normal blue dot.

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
     MKAnnotationView *anno = nil;
     //create a pin annotation view
MKPinAnnotationView  *pin=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"]autorelease];

    [pin setPinColor:MKPinAnnotationColorRed];
    pin.animatesDrop=YES;
    pin.canShowCallout = YES;
    pin.calloutOffset = CGPointMake(-5, 5);
    anno = pin;
    return anno;
}

How can i get it to drop pins and show the blue dot as well?

Thanks

like image 303
joec Avatar asked Nov 28 '22 11:11

joec


1 Answers

Really simple to fix, although unsure if this is the correct way to do it...

if (annotation == mapView.userLocation){
    return nil; //default to blue dot
}
like image 66
joec Avatar answered Dec 09 '22 22:12

joec