[英]iPhone - How do i get direction with degree based location
First I've implemented location manager functions in my class and whict are working fine, and gives me the current location. 首先,我在课堂上实现了位置管理器功能,并且运行正常,并提供了当前位置。 From that location I got how to get location degrees from here .
从那个位置我得到了如何从这里获得位置度的信息 。 but I'm not able to get the direction (ie North, South, East, West) I've referred this too.
但是我也找不到方向(即北,南,东,西),我也提到了这个方向 。 I want the location that I'm getting to be displayed in degrees with direction format like this .
我想那我越来越显示在度像方向格式的位置这个 。 ie location manager gives me +37.33019332,-122.02298792 and i want something like 37° 19' 49" N , -122° 1' 23" E .
即位置经理给我+ 37.33019332,-122.02298792,我想要的东西像是37°19'49“ N ,-122°1'23” E。 I'm getting all things just don't know how to get the last "N" and "E".
我正在获取所有东西,只是不知道如何获取最后的“ N”和“ E”。 If i use
CLLocation.course
for this I'm getting my direction course. 如果我为此使用
CLLocation.course
我正在我的方向课程。 Any help would be appreciated. 任何帮助,将不胜感激。
This is actually very simple. 这实际上非常简单。 Latitudes begin at 0° at the equator with the north pole being 90.0 and the south pole being -90.0.
纬度从赤道的0°开始,北极为90.0,南极为-90.0。 Basically, if the latitude is between 0 and 90, you're in the northern hemisphere and the southern hemisphere for latitude between 0 and -90.
基本上,如果纬度在0到90之间,那么您在北半球和南半球的纬度在0到-90之间。
Longitude basically works the same way. 经度基本上以相同的方式工作。 0° refers to the prime meridian which is the imaginary line that runs through Greenwich, England and a part of Africa.
0°表示本初子午线,它是一条穿过格林威治,英格兰和非洲部分地区的假想线。 A positive longitude up to 180° refers to locations east of the prime meridian, while negative longitudes refer to areas west of the prime meridian up to 180°.
最高经度为180°的正经度是指本初子午线以东的位置,而负经度是指本初子午线以西180度以内的区域。
Use this code and put CLLocationManagerDelegate at .h file 使用此代码并将CLLocationManagerDelegate放在.h文件中
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
updatedHeading = newHeading.magneticHeading;
float headingFloat = 0 - newHeading.magneticHeading;
rotateImg.transform = CGAffineTransformMakeRotation(headingFloat*radianConst);
float value = updatedHeading;
if(value >= 0 && value < 23)
{
compassFault.text = [NSString stringWithFormat:@"%f° N",value];
}
else if(value >=23 && value < 68)
{
compassFault.text = [NSString stringWithFormat:@"%f° NE",value];
}
else if(value >=68 && value < 113)
{
compassFault.text = [NSString stringWithFormat:@"%f° E",value];
}
else if(value >=113 && value < 185)
{
compassFault.text = [NSString stringWithFormat:@"%f° SE",value];
}
else if(value >=185 && value < 203)
{
compassFault.text = [NSString stringWithFormat:@"%f° S",value];
}
else if(value >=203 && value < 249)
{
compassFault.text = [NSString stringWithFormat:@"%f° SE",value];
}
else if(value >=249 && value < 293)
{
compassFault.text = [NSString stringWithFormat:@"%f° W",value];
}
else if(value >=293 && value < 350)
{
compassFault.text = [NSString stringWithFormat:@"%f° NW",value];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.