如何在GMSMapView上设置自定义标注标记(围绕一个点的动画环) [英] How set Custom Annotation markers ( animated rings around a point) on GMSMapView
问题描述
使用Google地图iOS SDK我已经实现了mapView
,因为我创建了如下标记:
/ /在地图的中心创建一个标记。
GMSMarker * marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86,151.20);
marker.title = @悉尼;
marker.snippet = @澳大利亚;
marker.icon = [UIImage imageNamed:@point1.png];
marker.map = mapView_;
但是我需要显示动画图像,即一些要显示的图像序列,一点,而不是原来的GMSMarker
序列图像是point1.png point2.png point3.png point4.png point5.png
任何人都可以帮助我实现这一目标。
$ b
- (RMMapLayer *)mapView:(RMMapView *)mpView layerForAnnotation:(RMAnnotation *)注释
{
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];
返回标记;
PulseRing.png 在中[UIImage imageNamed:@PulseRing.png]
是
获取参考资料:
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];
Using Google maps iOS SDK I have implemented a mapView in that i have created markers as follows
// 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_;
But i need to Display animated images ie some sequence of images to display, animated rings around a point, instead of original GMSMarker
sequence of images are point1.png point2.png point3.png point4.png point5.png
Can any one help me to achieve this
in
- (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 in [UIImage imageNamed:@"PulseRing.png"]
is
Getting reference from:
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"];
这篇关于如何在GMSMapView上设置自定义标注标记(围绕一个点的动画环)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!