简体   繁体   English

iPhone-如何获得基于学位的位置指导

[英]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.

相关问题 如何在iPhone中获取地图上的动态位置方向 - How to get dynamic location direction on map in iphone 如何在iPhone上获得方向? - how to get direction in iphone? 如何在iPhone的背景模式下获取当前位置? - How do i get the current location in the background mode in iPhone? 如何在iPhone SDK中获取位置名称 - How do i get name of a location in iPhone SDK Iphone-如何使图像连续旋转约60秒,然后朝另一个方向停止 - Iphone-How do I get an image to rotate continously for about 60 seconds and then stop in the other direction 使用当前位置和目标位置的经度和纬度,如何获取iphone的方向 - Using lattitude and longitude of the current location and destination location , how can we get the direction in iphone iPhone如何以编程方式用度数符号代替字符串中的字母o? - iPhone how do I programmatically substitute a degree symbol for the letter o in a string? 如何在不使用GPS或定位服务的情况下获取我的iPhone设备国家代码? - how do i get my iPhone device country code without using GPS or location service? 在iPhone中获取行车路线 - Get driving direction in iPhone 在iPhone上,如何向地图应用程序添加位置? - On the iphone, how do I add a location to the maps application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM