Created
April 26, 2018 09:12
-
-
Save lukewakeford/166d12af42c9c3fbed02b4d3308f4228 to your computer and use it in GitHub Desktop.
Google Maps Swift Camera Rotate 360 Smooth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.