Search code examples
iosgoogle-mapsgoogle-maps-sdk-ios

How to Blinking gms marker on gmsmap view


I am using google map , and I have used GMS Map view.In map view I have created one GMS marker for current location and it is updating every one second with current latitude and longitude value.I used this code:

 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;

But I want that this marker should be blinking in every second.Please tell me what I am doing wrong?


Solution

  • 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"];
    

    This is how to do a repeating fade in/out every second, except that the Google Maps iOS SDK (as of 1.8) won't obey the repeatCount or autoreverses properties. It fades, but never comes back.