系统定位
来源:互联网 发布:navicat for mysql安卓 编辑:程序博客网 时间:2024/04/27 22:49
#import"ViewController.h"
#import <CoreLocation/CoreLocation.h>
@interfaceViewController()<CLLocationManagerDelegate>
@property(nonatomic,retain)CLLocationManager*manger;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
/**
定位
- returns:
*/
self.manger= [[CLLocationManageralloc]init];
self.manger.delegate= self;
//距离刷新
self.manger.distanceFilter= 10;
//定位精度
self.manger.desiredAccuracy= kCLLocationAccuracyBestForNavigation;
//开始定位
[self.mangerstartUpdatingLocation];
//设置什么时候开始定位
//程序只要运行就会定位
[self.mangerrequestAlwaysAuthorization];
//程序运行就会定位
[self.mangerrequestWhenInUseAuthorization];
//计算经纬度之间的距离
[selfcountdistance];
}
-(void)countdistance{
CLLocation *location = [[CLLocationalloc]initWithLatitude:23.3longitude:113.33];
CLLocation *locationEnd = [[CLLocationalloc]initWithLatitude:40.60longitude:117.78];
//计算距离调用方法
CLLocationDistance distance = [locationdistanceFromLocation:locationEnd];
NSLog(@"distance ======= %f",distance);
}
-(void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray<CLLocation*> *)locations{
//获取用户位置的对象
CLLocation *location = [locationslastObject];
CLLocationCoordinate2D coordinate = location.coordinate;
NSLog(@"经度: %f, 纬度: %f",coordinate.latitude,coordinate.longitude);
//停止定位
[self.mangerstopUpdatingLocation];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#import <CoreLocation/CoreLocation.h>
@interfaceViewController()<CLLocationManagerDelegate>
@property(nonatomic,retain)CLLocationManager*manger;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
/**
定位
- returns:
*/
self.manger= [[CLLocationManageralloc]init];
self.manger.delegate= self;
//距离刷新
self.manger.distanceFilter= 10;
//定位精度
self.manger.desiredAccuracy= kCLLocationAccuracyBestForNavigation;
//开始定位
[self.mangerstartUpdatingLocation];
//设置什么时候开始定位
//程序只要运行就会定位
[self.mangerrequestAlwaysAuthorization];
//程序运行就会定位
[self.mangerrequestWhenInUseAuthorization];
//计算经纬度之间的距离
[selfcountdistance];
}
-(void)countdistance{
CLLocation *location = [[CLLocationalloc]initWithLatitude:23.3longitude:113.33];
CLLocation *locationEnd = [[CLLocationalloc]initWithLatitude:40.60longitude:117.78];
//计算距离调用方法
CLLocationDistance distance = [locationdistanceFromLocation:locationEnd];
NSLog(@"distance ======= %f",distance);
}
-(void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray<CLLocation*> *)locations{
//获取用户位置的对象
CLLocation *location = [locationslastObject];
CLLocationCoordinate2D coordinate = location.coordinate;
NSLog(@"经度: %f, 纬度: %f",coordinate.latitude,coordinate.longitude);
//停止定位
[self.mangerstopUpdatingLocation];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
0 0
- 定位系统
- 定位系统
- 系统定位
- 系统定位
- GPS车载定位系统
- Ubisense高精度定位系统
- 物联定位系统
- 公交车定位系统
- GPS定位系统
- 北斗星定位系统
- 各种定位系统
- android GPS定位系统
- IOS 定位系统实例
- 定位系统键盘
- Android GPS定位系统
- LBS打车定位系统
- “伽利略”卫星定位系统
- 11.3 地图 系统定位
- Leetcode 211. Add and Search Word - Data structure design
- 发出商品
- Log4j slf4j 配置简单介绍
- jQuery中html()、text()和val()的区别、jQuery中attr()和prop()的区别
- 新年目标计划
- 系统定位
- Android样式的开发:View Animation篇
- a标签中href属性与onclick事件的区别与用法
- Linux下安装PPAS(Postgres Plus Advanced Server)
- hdu3460Ancient Printer
- 软件开发技术:PRISM
- Gstreamer for android 编译
- iOS 内存管理详解
- 关于联网获取实时天气的小练习