简体   繁体   中英

Mapkit: Pulsating blue dot and circle

Im trying to get the pulsating blue dot and circle when users zoom in to their current location. But its not appearing quite well. I understand that the codes needed to be places in the viewForAnnotation. Here are the relevant codes. Tell me if you need more! Thanks aloot

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

if ([annotation isKindOfClass:[MKUserLocation class]])
    return nil;  //return nil to use default blue dot view

//NSLog(@"View for Annotation is called");
MKPinAnnotationView *pin=[[MKPinAnnotationView alloc] 
                          initWithAnnotation:annotation reuseIdentifier:nil];
pin.userInteractionEnabled=TRUE;

[pin setPinColor:MKPinAnnotationColorGreen];
pin.canShowCallout = YES;
pin.animatesDrop = YES;

MapEvent* event = (MapEvent*)annotation;
NSLog(@"%@",event.uniqueID);

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:@selector(clickAnnotation:) forControlEvents:UIControlEventTouchUpInside];
[rightButton setTitle:event.uniqueID forState:UIControlStateNormal];

pin.rightCalloutAccessoryView = rightButton;

return pin;

}

要用圆圈显示蓝色圆点,请将MKMapView的showsUserLocation属性设置为YES。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM