iPhone指南针显示到特定位置 [英] iPhone compass showing to a specific location
本文介绍了iPhone指南针显示到特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Objective-c的新手,所以如果我的问题太垃圾,我想道歉。
I am new to objective-c so I want to apologize if my question is too rubbish.
我正在编程指南针然而,它正在工作(谢谢到教程)。
给出实际位置(经度和纬度)。
罗盘内的箭头是否可以显示指向特定位置(经度2和纬度2)的方向?
我读过我必须考虑iphone的磁性和真实标题。
I am programming a compass and yet, it is working (thanks to a tutorial). Actual position (Longitude and Lattitude) is given. Is it possible that my arrow within the compass can show me the direction to a specific location (longitude2 and lattitude2)? I have read that I have to consider the magnetic and the true heading of the iphone.
推荐答案
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
double heading = newHeading.trueHeading; //in degree relative to true north
double bearing = ... //get current bearing in degree relative to true north
//with the JS library mentioned below it would be something like
//bearing = userLoc.bearingTo(destionation);
//just two lines, the the sake of the example
double rotationInDegree = (bearing - heading); //the important line
rotationInDegree = fmod((rotationInDegree + 360), 360); //just to be on the safe side :-)
compassViewPerhapsAsImage.transform=CGAffineTransformMakeRotation(DegreesToRadians(rotationInDegree));
}
计算方位的好链接:
- http:// www。 moving-type.co.uk/scripts/latlong.html 与eplanations和Javascript示例,但很容易转换! : - )
- https://github.com/tadelv/CLLocation -Bearing as Objective C Project
- http://www.movable-type.co.uk/scripts/latlong.html with eplanations and Javascript exampless, but very easy to convert! :-)
- https://github.com/tadelv/CLLocation-Bearing as Objective C Project
这篇关于iPhone指南针显示到特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文