core animation - Animating GMSMarker in a circular path -


i understand how animation other calayers in circular path based on question: iphone - how make circle path cakeyframeanimation?

however, gmsmarkerlayer special subclass of calayers not seem respond "position" keypath (following instructions in link nothing can visibly see) instead respond "latitude" , "longitude" keypaths instead.

here's code i've tried:

cakeyframeanimation *circlepathanimation = [cakeyframeanimation animationwithkeypath:@"position"]; cgmutablepathref circularpath = cgpathcreatemutable(); cgrect pathrect = cgrectmake(marker.position.latitude, marker.position.longitude, 0.001, 0.001); cgpathaddellipseinrect(circularpath, null, pathrect); circlepathanimation.path = circularpath; circlepathanimation.duration = 1.0f; circlepathanimation.repeatcount = huge_valf;  [marker.layer addanimation:circlepathanimation forkey:[nsstring stringwithformat:@"circular-%@", marker.description]]; cgpathrelease(circularpath); 

since keyframe animation use "position" keypath, how can convert 2 separate keypaths (latitude , longitude) can animate marker in circle on map?

any appreciated.

as cannot use "position" keypath animating, ended animating using "latitude" , "longitude" keypaths separately.

first calculate points , add them 2 separate arrays, 1 latitude value (y) , 1 longitude (x) , use values property in cakeyframeanimation animate. create 2 cakeyframeanimation objects (1 each axis) , group them using caanimationgroup , animate them form circle.

in equation vary length of radius on each axis can generate oval path.

    nsmutablearray *latitudes = [nsmutablearray arraywithcapacity:21];     nsmutablearray *longitudes = [nsmutablearray arraywithcapacity:21];     (int = 0; <= 20; i++) {         cgfloat radians = (float)i * ((2.0f * m_pi) / 20.0f);          // calculate x,y coordinate using angle         cgfloat x = hdist * cosf(radians);         cgfloat y = vdist * sinf(radians);          // calculate real lat , lon using         // current lat , lon center points.         y = marker.position.latitude + y;         x = marker.position.longitude + x;           [longitudes addobject:[nsnumber numberwithfloat:x]];         [latitudes addobject:[nsnumber numberwithfloat:y]];     }      cakeyframeanimation *horizontalanimation = [cakeyframeanimation animationwithkeypath:@"longitude"];     horizontalanimation.values = longitudes;     horizontalanimation.duration = duration;      cakeyframeanimation *verticleanimation = [cakeyframeanimation animationwithkeypath:@"latitude"];     verticleanimation.values = latitudes;     verticleanimation.duration = duration;      caanimationgroup *group = [[caanimationgroup alloc] init];     group.animations = @[horizontalanimation, verticleanimation];     group.duration = duration;     group.repeatcount = huge_valf;     [marker.layer addanimation:group forkey:[nsstring stringwithformat:@"circular-%@",marker.description]]; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -