Mapkit:脉动的蓝点和圆圈

发布于 2024-10-11 19:59:30 字数 1049 浏览 1 评论 0原文

当用户放大到当前位置时,我试图获得脉动的蓝点和圆圈。但它看起来不太好。我知道代码需要放在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笑百媚生 2024-10-18 19:59:30

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文