百度地图点击大头针在弹出的气泡上加按钮

- (BMKAnnotationView *)mapView:(BMKMapView *)view viewForAnnotation:(id <BMKAnnotation>)annotation
{
        static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
        BMKPinAnnotationView*
        customPinView = (BMKPinAnnotationView *)[view dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
        
        if (!customPinView) {
            customPinView = [[BMKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
            customPinView.pinColor = BMKPinAnnotationColorRed;//设置大头针的颜色
            customPinView.animatesDrop = YES;
            customPinView.canShowCallout = YES;
            customPinView.draggable = YES;//可以拖动

                //添加tips上的按钮
                UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
                [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
                customPinView.rightCalloutAccessoryView = rightButton;
        }else{
            customPinView.annotation = annotation;
        }
        return customPinView;
}

猜你喜欢

转载自blog.csdn.net/kkxmforever/article/details/44224527