iPhone指南针显示到特定位置
发布时间:2020-12-14 17:29:54 所属栏目:百科 来源:网络整理
导读:我是 Objective-c的新手,所以如果我的问题太垃圾,我想道歉. 我正在编程指南针然而,它正在工作(感谢教程). 给出实际位置(经度和纬度). 罗盘内的箭头是否可以显示指向特定位置(经度2和纬度2)的方向? 我已经读过,我必须考虑iphone的磁性和真实标题. 解决方法 -
我是
Objective-c的新手,所以如果我的问题太垃圾,我想道歉.
我正在编程指南针然而,它正在工作(感谢教程). 解决方法- (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.movable-type.co.uk/scripts/latlong.html有eplanations和Javascript exampless,但很容易转换! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |