开发者

Mapkit: Pulsating blue dot and circle

开发者 https://www.devze.com 2023-02-04 03:23 出处:网络
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 viewForAnnotat

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;
开发者_如何学Python

}


To show the blue dot with the circle, set the showsUserLocation property of the MKMapView to YES.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号