我正在尝试为应用程序开发一个指南针,它在地图上有一组注释.我希望能够选择一个注释,然后让指南针将用户指向所选位置.
我已经计算了从用户位置到注释位置的degress,我有磁性标题和iPhone的真实标题.我也知道如何旋转图像.但我无法弄清楚下一步是什么.
用户位置和注释位置之间的度数计算如下:
// get user location
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
float x1 = coordinate.latitude;
float y1 = coordinate.longitude;
float x2 = [annLatitude floatValue];
float y2 = [annLongitude floatValue];
float dx = (x2 - x1);
float dy = (y2 - y1);
if (dx == 0) {
if (dy > 0) {
result = 90;
}
else …Run Code Online (Sandbox Code Playgroud)