शीर्ष पर अपना स्थान प्रबंधक के प्रतिनिधि विधि में ज फ़ाइल
float GeoAngle;
में इस
#define RadiansToDegrees(radians)(radians * 180.0/M_PI)
#define DegreesToRadians(degrees)(degrees * M_PI/180.0)
परिभाषित चर को परिभाषित: -
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
GeoAngle = [self setLatLonForDistanceAndAngle:newLocation];
}
और समारोह इस प्रकार होगी : -
-(float)setLatLonForDistanceAndAngle:(CLLocation *)userlocation
{
float lat1 = DegreesToRadians(userlocation.coordinate.latitude);
float lon1 = DegreesToRadians(userlocation.coordinate.longitude);
float lat2 = DegreesToRadians(locLat);
float lon2 = DegreesToRadians(locLon);
float dLon = lon2 - lon1;
float y = sin(dLon) * cos(lat2);
float x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon);
float radiansBearing = atan2(y, x);
if(radiansBearing < 0.0)
{
radiansBearing += 2*M_PI;
}
return radiansBearing;
}
आप GeoAngle चर में लगातार अद्यतन कोण प्राप्त करेंगे। तीर को गंतव्य स्थान पर घुमाने के लिए तीर की छवि लें और इसे तीर ImageView के IBOutlet को असाइन करें और इसे अद्यतन अद्यतन विधि पर घुमाएं।
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
float direction = -newHeading.trueHeading;
arrowImageView.transform=CGAffineTransformMakeRotation((direction* M_PI/180)+ GeoAngle);
}
देखें [इस] (http://stackoverflow.com/questions/6745131/how-can-we-find-the-angle-between-two-locations-defined-by-latitude-or-longitude) और [यह] (http://www.movable-type.co.uk/scripts/latlong.html) संदर्भ –