我正在使用谷歌地图,并且我使用了 GMS map View 。在 map View 中,我为当前位置创建了一个 GMS 标记,它每隔一秒更新一次当前的纬度和经度值。我使用了以下代码:
mMapView = [[GMSMapView alloc]init];
mMapView.delegate = self;
mMapView.myLocationEnabled = YES;
mMapView.frame = CGRectMake(0, 95, self.view.frame.size.width,self.view.frame.size.height -205);
GMSMarker *disMarker = [GMSMarker markerWithPosition:coordinateEndLocation];
disMarker.snippet = @"current Location";
disMarker.animated = YES;
disMarker.map = mMapView;
但我希望这个标记每秒都在闪烁。请告诉我我做错了什么?
最佳答案
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];
[yourMarker.layer addAnimation:theAnimation forKey:@"animateOpacity"];
这是每秒重复淡入/淡出的方法,除了 Google Maps iOS SDK(从 1.8 开始)不会遵守
repeatCount
或 autoreverses
特性。它会消失,但永远不会回来。
关于ios - 如何在 gmsmap View 上闪烁 gms 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20266921/