1. #import <UIKit/UIKit.h>
  2. #import <CoreLocation/CoreLocation.h>
  3.  
  4. @interface ViewController : UIViewController<CLLocationManagerDelegate>
  5. @property (retain, nonatomic) IBOutlet UITextField *latTxt;
  6. @property (retain, nonatomic) IBOutlet UITextField *lontTxt;
  7. @property (retain, nonatomic) IBOutlet UITextField *heighttxt;
  8.  
  9. @end
  10.  
  11. #import "ViewController.h"
  12.  
  13. @interface ViewController ()
  14.  
  15. //定位管理
  16. @property(nonatomic,retain)CLLocationManager *locationManager;
  17. @end
  18.  
  19. @implementation ViewController
  20.  
  21. - (void)viewDidLoad
  22. {
  23. [super viewDidLoad];
  24. self.locationManager=[[[CLLocationManager alloc] init] autorelease];
  25. _locationManager.delegate=self;
  26. _locationManager.desiredAccuracy=kCLLocationAccuracyBest;//设备使用电池的。
  27. _locationManager.distanceFilter=1000.0;
  28.  
  29. // Do any additional setup after loading the view, typically from a nib.
  30. }
  31.  
  32. -(void)viewDidAppear:(BOOL)animated{
  33. [super viewDidAppear:animated];
  34. //开始定位
  35. [_locationManager startUpdatingLocation];
  36. }
  37.  
  38. -(void)viewDidDisappear:(BOOL)animated{
  39. [super viewDidDisappear: animated];
  40. //停止定位
  41. [_locationManager stopUpdatingLocation];
  42. }
  43.  
  44. #pragma mark -locationManager delegate
  45. -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
  46. NSLog(@"--->%@",locations);
  47. CLLocation *location=[locations lastObject];
  48. self.latTxt.text=[NSString stringWithFormat:@"%3.5f",location.coordinate.latitude];
  49. self.lontTxt.text=[NSString stringWithFormat:@"%3.5f",location.coordinate.longitude];
  50. self.heighttxt.text=[NSString stringWithFormat:@"%3.5f",location.altitude];
  51. }
  52.  
  53. -(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
  54. NSLog(@"--error-->%@",error.localizedDescription);
  55. }
  56.  
  57. - (void)didReceiveMemoryWarning
  58. {
  59. [super didReceiveMemoryWarning];
  60. // Dispose of any resources that can be recreated.
  61. }
  62.  
  63. - (void)dealloc {
  64. [_locationManager release];
  65. [_latTxt release];
  66. [_lontTxt release];
  67. [_heighttxt release];
  68. [super dealloc];
  69. }

ios中地图定位的更多相关文章

  1. IOS中GPS定位偏移纠正(适用于Google地图)

    在这个神奇的国度里,我们总得学习一些有中国特色的东东,例如“火星坐标”.也许有人还不知道这是什么玩意,我就简要介绍一下吧.      如果你有带GPS模块的智能手机,打开定位功能,然后访问Google ...

  2. ios 8 地图定位

    在xcode6在 苹果公司定位方法改变地图,谁也无法使用 错误说明:Trying to start MapKit location updates without prompting for loca ...

  3. ios中地图

    参考文章  http://blog.csdn.net/tangaowen/article/details/6527901 http://www.cnblogs.com/tangbinblog/arch ...

  4. iOS 9 地图定位崩溃 n: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'

    报错详情: *** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:], /BuildRoot/ ...

  5. iOS中城市定位功能的实现

    引入框架:CoreLocation .h文件 引入CoreLocation/CoreLocation.h @interface WeatherViewController :UIViewControl ...

  6. Ios开发之定位CLLocationManager

    Ios中的定位功能是通过 Core Location框架实现的.它和地图开发框架是相互独立的.在Core Location中主要实现了定位和地理编码的功能! 下面我们就来介绍一下它的属性,方法和代理方 ...

  7. iOS原生地图开发详解

    在上一篇博客中:http://my.oschina.net/u/2340880/blog/414760.对iOS中的定位服务进行了详细的介绍与参数说明,在开发中,地位服务往往与地图框架结合使用,这篇博 ...

  8. iOS中的地图和定位

    文章摘自http://www.cnblogs.com/kenshincui/p/4125570.html#location  如有侵权,请联系删除. 概览 现在很多社交.电商.团购应用都引入了地图和定 ...

  9. IOS中使用百度地图定位后获取城市坐标,城市名称,城市编号信息

    IOS中使用百度地图定位后获取城市坐标,城市名称,城市编号信息 /**当获取到定位的坐标后,回调函数*/ - (void)didUpdateBMKUserLocation:(BMKUserLocati ...

随机推荐

  1. File targeting 'AMD64' is not compatible with the project's target platform 'x86' 解决方法

     我在使用vs2010制作64位安装包时出现了以下问题: File targeting 'AMD64' is not compatible with the project's target plat ...

  2. [leetcode]Remove Duplicates from Sorted Array II @ Python

    原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ 题意: Follow up for &quo ...

  3. IOS开发之自定义UITabBarController

    UITabBarController是开发中经常会用到的一个视图控制器,但是默认的UITabBarController经常不能够完全满足我们的需求,所以我们经常需要自定义一个UITabBarContr ...

  4. laravel 开启sql调试

    打开app\Providers\AppServiceProvider.PHP,在boot方法中添加如下内容 public function boot() { //sql调试 $sql_debug = ...

  5. 推文《阿里凑单算法首次公开!基于Graph Embedding的打包购商品挖掘系统解析》笔记

    推文<阿里凑单算法首次公开!基于Graph Embedding的打包购商品挖掘系统解析>笔记 从17年5月份开始接触Graph Embedding,学术论文读了很多,但是一直不清楚这技术是 ...

  6. Java-Shiro(四):Shiro

    https://blog.csdn.net/visket2008/article/details/78539334 不错的视屏教程,很实用:https://www.bilibili.com/video ...

  7. Android版-微信APP支付

    首发地址: Android版-微信APP支付 欢迎留言.转发 微信极速开发系列文章(微信支付.授权获取用户信息等):点击这里 目录 1.注册账号.开发者认证 2.添加应用 3.申请微信支付 4.技术开 ...

  8. selenium之 chromedriver与chrome版本映射表(更新至v2.38)

    https://blog.csdn.net/huilan_same/article/details/51896672 看到网上基本没有最新的chromedriver与chrome的对应关系表,便兴起整 ...

  9. linux下更改主机名方法hostname

    一.永久修改修改/etc/sysconfig/network,在里面指定主机名称HOSTNAME=然后执行命令hostname 主机名这个时候可以注销一下系统,再重登录之后就行了. 或者修改/etc/ ...

  10. 【BLE】CC2541之加入自己定义任务

    本篇博文最后改动时间:2017年01月06日,11:06. 一.简单介绍 本文介绍怎样在SimpleBLEPeripheralproject中.加入一个香瓜任务. (香瓜任务与project原有任务相 ...