Mapkit:脉动的蓝点和圆圈
当用户放大到当前位置时,我试图获得脉动的蓝点和圆圈。但它看起来不太好。我知道代码需要放在 viewForAnnotation 中。这是相关代码。如果您需要更多,请告诉我!非常感谢
- (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;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要显示带有圆圈的蓝点,请将 MKMapView 的
showsUserLocation
属性设置为 YES。To show the blue dot with the circle, set the
showsUserLocation
property of the MKMapView to YES.