I want to shake the google map marker in iOS Swift

前端 未结 2 651
小鲜肉
小鲜肉 2021-01-15 16:46

I am working on a project where I wants to shake the marker on google Map. I am using the custom marker icon to represent on the map. Like a head of person is shaking. I don

2条回答
  •  长发绾君心
    2021-01-15 16:52

    You can use marker property to rotate your marker ,

    marker.rotation =  (you_angle_in_degree) * M_PI / 180.0f; 
     //  convert  degree to radian 
    

    The Horizontally Shake animation you can get after some time interval change the degree for of the rotation , you can use timer ,

      // create a timer
      timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
    
     func timerAction() {
           // Place you aniamtion logic here , 
           // every 0.5 second change the rotation of your maker
        }
    

提交回复
热议问题