ios - 如何在 gmsmap View 上闪烁 gms 标记

标签 ios google-maps google-maps-sdk-ios

我正在使用谷歌地图,并且我使用了 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 开始)不会遵守 repeatCountautoreverses特性。它会消失,但永远不会回来。

关于ios - 如何在 gmsmap View 上闪烁 gms 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20266921/

相关文章:

google-maps - 如何更改谷歌地图信息窗口的位置

google-maps - flutter 中的 map View

iOS map 和谷歌地图 SDK - 使用坐标

objective-c - 更改 UISegmentedControl selectedSegmentIndex 不会更改所选索引

java - 如何在 Google map 上存储和检索地点

ios - setValue(value, forKey) 以某种方式改变了 Realm 中的整个数组

ios - 重用的 GMSMapView 在第一次使用时有效,但不适用于任何进一步的 ViewControllers

IOS 谷歌地图防滑边界

ios - 为什么 setClipsToBounds :NO disables setCornerRadius: for UItableview?

ios - UIcollectionView 自定义形状 Objective C