Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapKit blue dot not visible when using custom annotations

I am not able to see the Blue current location dot when I use custom annotations

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

    MKAnnotationView *customAnnotationView=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];

    UIImage *pinImage = [UIImage imageNamed:@"ann.png"];
    [customAnnotationView setImage:pinImage];

    customAnnotationView.canShowCallout = YES;
                                                                                                 
    //UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ann.png"]];
    //customAnnotationView.leftCalloutAccessoryView = leftIconView;

    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
    customAnnotationView.rightCalloutAccessoryView = rightButton;

    return customAnnotationView;
}
like image 370
user582835 Avatar asked Nov 27 '25 20:11

user582835


2 Answers

if (annotation == map.userLocation) {
        return nil;
    }

Add this.:d

like image 89
Alex Terente Avatar answered Nov 30 '25 12:11

Alex Terente


I got the answer now. Just need to add the following lines to the above code at the end just before return customAnnotationView;

if (annotation == mapView.userLocation) {
NSLog(@"nil"); return nil; }

thanks :)

like image 21
user582835 Avatar answered Nov 30 '25 12:11

user582835



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!