如何在gmsmap视图上闪烁gms标记

时间:2013-11-28 13:01:08

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

我正在使用谷歌地图,我使用了GMS地图视图。在地图视图中,我为当前位置创建了一个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;

但我希望这个标记应该每秒闪烁。请告诉我我做错了什么?

2 个答案:

答案 0 :(得分:0)

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属性。它消失了,但永远不会回来。

答案 1 :(得分:0)

Swift 5.0 通过blinkMarker方法传递 GMSMarker 对象。

//gets called initially on app launch to get files to be played
export function getScheduleFiles(){
    return (dispatch) => {
        getOfflineNextScheduleFiles().then((files)=>{//get offline files/schedule first
            plainFiles = convertToArray(files)
            dispatch({type: SCHEDULE_REFRESHED, data:plainFiles,nextFileIndex:0});
        }).catch((error)=>{//if offline schedules is not available to play, refresh online
            triggerPlaylistsRefresh().then((files)=>{
                plainFiles = convertToArray(files)
                dispatch({type: SCHEDULE_REFRESHED, data:plainFiles,nextFileIndex:0});
            }).catch((error)=>{
                console.log("nothing to play")
                dispatch({type: PLAY_NEXT_FILE, nextFileIndex:0});
                showToastMessage(I18n.t("ErrorMessage.NoSchedulesAvailableForCurrentTimeError"))
            })
        })
    }
}

//get called from PlaylistPlayerScreen after each file played
export function playNextFile(files,filePlayedIndex){
    return (dispatch) => {
        if(filePlayedIndex < files.length-1) {
            dispatch({type: PLAY_NEXT_FILE, nextFileIndex:filePlayedIndex+1});
          }else {
            console.log("all files played")
            dispatch({type: PLAY_NEXT_FILE, nextFileIndex:0});
          }
    }
}