Skip to content

Instantly share code, notes, and snippets.

@lukewakeford
Created April 26, 2018 09:12
Show Gist options
  • Save lukewakeford/166d12af42c9c3fbed02b4d3308f4228 to your computer and use it in GitHub Desktop.
Save lukewakeford/166d12af42c9c3fbed02b4d3308f4228 to your computer and use it in GitHub Desktop.
Google Maps Swift Camera Rotate 360 Smooth
var timer:Timer!
var degree = 0
@objc func rotate() {
// assumes google map called 'map'
self.map.animate(toBearing: CLLocationDirection(degree))
if degree == 360 {
timer.invalidate() // comment out this line for continual rotation
degree = 0
}
degree += 18
}
func startRotation() {
timer = Timer.scheduledTimer(timeInterval: 0.18, target: self, selector: #selector(rotate), userInfo: nil, repeats: true)
}
@lukewakeford
Copy link
Author

Wrote this for a screen capture where I wanted to rotate around a marker and then loop the video and export in to a gif.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment