在 iPhone 中获取当前位置提供程序详细信息

Posted

技术标签:

【中文标题】在 iPhone 中获取当前位置提供程序详细信息【英文标题】:Getting Current Location's Provider Detail in iPhone 【发布时间】:2011-05-10 11:38:15 【问题描述】:

我已经实现了LocationManager 并在didUpdateToLocation: 中更新了当前位置,一切正常。现在我想实现网络三角测量,据我所知,位置服务会自动执行此操作。只需在您的LocationManager 中请求“最佳精度”,如果 GPS 不可用或不稳定,它将进行网络三角测量。

问题是我想获取位置提供者(GPS、网络),即提供位置的位置提供者。如何在我的应用程序中获取位置的提供者详细信息。

【问题讨论】:

【参考方案1】:

在这里查看我的答案:Corelocation and assisted gps iPhone

这应该可以帮助您区分 GPS 和三角测量。

【讨论】:

【参考方案2】:
#import <UIKit/UIKit.h> 
#import <CoreLocation/CoreLocation.h>

@interface RootViewController : UIViewController<CLLocationManagerDelegate>

 

CLLocationManager   *locationManager;


 
@property (nonatomic, retain) CLLocationManager *locationManager;

 @end




The implementation of our view controller is as follows:
#import "RootViewController.h"
 #import <objc/runtime.h>

@implementation RootViewController

@synthesize locationManager;

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation


NSLog(@"Latitude = %f", newLocation.coordinate.latitude);


 NSLog(@"Longitude = %f", newLocation.coordinate.longitude);


【讨论】:

我们如何知道当前位置来自 GPS 或网络??

以上是关于在 iPhone 中获取当前位置提供程序详细信息的主要内容,如果未能解决你的问题,请参考以下文章