Bounce Animation on Google Map Marker in iOS ?? [Objective-c] -


i want continuos bounce animation on google map marker in ios.

[animation below link , click on marker -->] ,

https://developers.google.com/maps/documentation/javascript/examples/marker-animations

can implement bounce animation in iphone?

i creating marker animated appear want animate marker bounce effect continuously.

gmsmarker *marker = [gmsmarker markerwithposition:position]; marker.title = @"delhi"; marker.zindex=1; marker.icon=[uiimage imagenamed:@"marker_user.png"]; // appearaniamtion marker.appearanimation = kgmsmarkeranimationpop;  marker.infowindowanchor = cgpointmake(0.44f, 0.30f); marker.map = mapview_; 

i wanted add marker on google map animate indicated current user. not able exact bounce animation link above mentioned , alternate way highlight marker did using scale animation.
... enter image description here

to animation .

 gmsmarker *markeruser;  nstimer *timer;  int imagescale; 

add marker on map

 imagescale=15;      cllocationcoordinate2d position = cllocationcoordinate2dmake(userlat, userlng);     markeruser = [gmsmarker markerwithposition:position];     markeruser.title = @"you here";     markeruser.icon=[self image:[uiimage imagenamed:@"marker_user.png"] scaledtosize:cgsizemake(25.0f,40.0f)];   // initial marker size     markeruser.appearanimation = kgmsmarkeranimationpop;     markeruser.infowindowanchor = cgpointmake(0.44f, 0.30f);     markeruser.map = mapview_; 

start timer when marker added on map, , change icon of marker different size .

 timer =  [nstimer scheduledtimerwithtimeinterval:0.1                                      target:self                                    selector:@selector(targetmethod:)                                    userinfo:nil                                     repeats:yes]; 

at every 0.1 seconds tragetmethod fired , here can scale icon image , reassign marker icon

-(void)targetmethod:(nstimer *)timer {      if (imagescale<30) {          markeruser.icon=[self image:[uiimage imagenamed:@"marker_user.png"] scaledtosize:cgsizemake(imagescale,imagescale*1.5)];          imagescale+=1;      }     else{         imagescale=15;           markeruser.icon=[self image:[uiimage imagenamed:@"marker_user.png"] scaledtosize:cgsizemake(imagescale,imagescale*1.5)];     }  } 

and here method will scale your uiimage

- (uiimage *)image:(uiimage*)originalimage scaledtosize:(cgsize)size {     //avoid redundant drawing     if (cgsizeequaltosize(originalimage.size, size))     {         return originalimage;     }      //create drawing context     uigraphicsbeginimagecontextwithoptions(size, no, 0.0f);      //draw     [originalimage drawinrect:cgrectmake(0.0f, 0.0f, size.width, size.height)];      //capture resultant image     uiimage *image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      //return image     return image; } 

this may solve problem of guys looking such animation.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -