ios - 如何在 GMSMapView 上设置自定义注释标记(点周围的动画环)

标签 ios objective-c google-maps mapkit google-maps-sdk-ios

使用 Google map iOS SDK 我实现了一个 mapView 因为我创建了如下标记

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";

marker.icon = [UIImage imageNamed:@"point1.png"]; 

marker.map = mapView_;

但我需要显示动画图像,即要显示的一些图像序列,一个点周围的动画环,而不是原始的 GMSMarker

图像序列是point1.png point2.png point3.png point4.png point5.png

谁能帮我实现这个目标

最佳答案

- (RMMapLayer *)mapView:(RMMapView *)mpView layerForAnnotation:(RMAnnotation *)annotation
{

  UIImageView *pulseRingImg = [[UIImageView alloc] initWithFrame: CGRectMake(-30, -30, 78, 78)];
    pulseRingImg.image = [UIImage imageNamed:@"PulseRing.png"];
     pulseRingImg.userInteractionEnabled = NO;

    CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.xy"];
    theAnimation.duration=2.0;
    theAnimation.repeatCount=HUGE_VALF;
    theAnimation.autoreverses=NO;
    pulseRingImg.alpha=0;
    theAnimation.fromValue=[NSNumber numberWithFloat:0.0];
    theAnimation.toValue=[NSNumber numberWithFloat:1.0];
    pulseRingImg.alpha = 1;
    [pulseRingImg.layer addAnimation:theAnimation forKey:@"pulse"]; 
     pulseRingImg.userInteractionEnabled = NO;

    [mapView addSubview:pulseRingImg];
    [marker addSublayer:pulseRingImg.layer];

 return marker;

}

PulseRing.png [UIImage imageNamed:@"PulseRing.png"]

PulseRing.png

获取引用:

ios - how to do a native "Pulse effect" animation on a UIButton

CABasicAnimation *theAnimation;

theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration=1.0;
theAnimation.repeatCount=HUGE_VALF;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.0];
[myButton.layer addAnimation:theAnimation forKey:@"animateOpacity"]; 

关于ios - 如何在 GMSMapView 上设置自定义注释标记(点周围的动画环),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18529248/

相关文章:

java - GWT GoogleMaps 使用样式隐藏默认图层

javascript - 将图像添加到多个谷歌地图信息窗口

ios - 点击 subview Controller 或父 View Controller 时处理键盘关闭的替代方法?

ios - 如何从 MWPhoto 对象中获取 UIImage?

objective-c - 如何使用 Objective-c 在 Amazon S3 上创建文件夹

objective-c - cmake - 设置 - xcode 属性 - 隐式链接 objective-c 运行时支持

javascript - Marker 的 Z-index 高于 Infobox

ios - 无法获取远程 View Controller ,错误为 : Error: domain=_UIViewServiceInterfaceErrorDomain, code=2

iphone - 如何在 Objective C 中从 NSString 中拆分换行符

ios - objective c UITableView 无法使用自定义单元格和 View 平滑滚动