当用户放大到当前位置时,我试图获得脉动的蓝点和圆圈。但它看起来不太好。我知道代码需要放在viewForAnnotation中。以下是相关代码。告诉我你是否需要更多!谢谢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;
}
答案 0 :(得分:4)
要显示圆圈的蓝点,请将MKMapView的showsUserLocation
属性设置为YES。