Note : - (Integrated AppleMap
Understanding iOS's
location concepts completely helps to resolve any issue regarding AppleMap
.
To move map Pin or AnnotationView , we can use the CoreLocation
framework which outputs data related to the users current location.
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager:CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.startUpdatingHeading()
}
func locationManager(manager: CLLocationManager!, didUpdateHeading heading: CLHeading!) {
// This will print out the direction the device is heading
println(heading.magneticHeading) }
}
}
In the above example, "heading.magneticHeading
" will output a value representing the direction the device is pointed at.
The next step is to use those values and rotate your AnnotationView
or Pin
accordingly.
CGAffineTransformMakeRotation
can help with this.
For example if you want to rotate to imageview to point to northeast, which would require a degree value of 45, your code might look something like this.
float degrees = 45
imageView.transform = CGAffineTransformMakeRotation(degrees * M_PI/180)
Just be aware that CGAffineTransformMakeRotation()
expects a radian value, in the example above we've converted degrees to radians by multiplying degrees with the number of half circles.
Following links really helpful :
Finally Resolved my issue. Hope this complete answer helps other too.