#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h> @interface ViewController : UIViewController<CLLocationManagerDelegate>
@property (retain, nonatomic) IBOutlet UITextField *latTxt;
@property (retain, nonatomic) IBOutlet UITextField *lontTxt;
@property (retain, nonatomic) IBOutlet UITextField *heighttxt; @end #import "ViewController.h" @interface ViewController () //定位管理
@property(nonatomic,retain)CLLocationManager *locationManager;
@end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad];
self.locationManager=[[[CLLocationManager alloc] init] autorelease];
_locationManager.delegate=self;
_locationManager.desiredAccuracy=kCLLocationAccuracyBest;//设备使用电池的。
_locationManager.distanceFilter=1000.0; // Do any additional setup after loading the view, typically from a nib.
} -(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//开始定位
[_locationManager startUpdatingLocation];
} -(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear: animated];
//停止定位
[_locationManager stopUpdatingLocation];
} #pragma mark -locationManager delegate
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
NSLog(@"--->%@",locations);
CLLocation *location=[locations lastObject];
self.latTxt.text=[NSString stringWithFormat:@"%3.5f",location.coordinate.latitude];
self.lontTxt.text=[NSString stringWithFormat:@"%3.5f",location.coordinate.longitude];
self.heighttxt.text=[NSString stringWithFormat:@"%3.5f",location.altitude];
} -(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
NSLog(@"--error-->%@",error.localizedDescription);
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (void)dealloc {
[_locationManager release];
[_latTxt release];
[_lontTxt release];
[_heighttxt release];
[super dealloc];
}

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. 大数据开发实战:离线大数据处理的主要技术--Hive,概念,SQL,Hive数据库

    1.Hive出现背景 Hive是Facebook开发并贡献给Hadoop开源社区的.它是建立在Hadoop体系架构上的一层SQL抽象,使得数据相关人员使用他们最为熟悉的SQL语言就可以进行海量数据的处 ...

  2. Android -- Handling back button press Inside Fragments

    干货(1) 首先创建一个抽象类BackHandledFragment,该类有一个抽象方法onBackPressed(),所有BackHandledFragment的子类在onBackPressed方法 ...

  3. 精确率、召回率、F1 值、ROC、AUC 各自的优缺点是什么?

    https://www.52ml.net/19370.html 精度.召回.F1点直观理解 图片来自:http://blog.csdn.net/marising/article/details/654 ...

  4. 开源项目kcws代码分析--基于深度学习的分词技术

    http://blog.csdn.net/pirage/article/details/53424544 分词原理 本小节内容参考待字闺中的两篇博文: 97.5%准确率的深度学习中文分词(字嵌入+Bi ...

  5. Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十八)ES6.2.2 增删改查基本操作

    #文档元数据 一个文档不仅仅包含它的数据 ,也包含 元数据 —— 有关 文档的信息. 三个必须的元数据元素如下:## _index    文档在哪存放 ## _type    文档表示的对象类别 ## ...

  6. ubuntu16.04下部署tomcat9和java8启动一次需要七八分钟

    一.环境如下 Ubuntu16.04  +tomcat9+openjdk1.8 二.问题 在tomcat的bin下执行./startup.sh 如下图没有问题 root@bogon:/usr/apac ...

  7. Bridging and Bonding with CentOS 6.5

    eth0和eth1要做bond,然后kvm虚拟机通过bridge与外界通信. 那么就要在bond上做bridge.配置文件例如以下,实測这样配置,能够从kvm虚拟机ping通外界拓扑. ifcfg-e ...

  8. 关于Windows勒索病毒以及445端口防护

    前两天,与这个周末,5月12日起,Onion.WNCRY两类敲诈者病毒变种在全国乃至全世界大范围内出现爆发态势,大量个人和企业.机构用户中招. 与以往不同的是,这次的新变种病毒添加了NSA(美国国家安 ...

  9. 微信小程序 - 支持html空格(提示)

    仅限于text标签,decode参数:官方api.

  10. 用Gearman分发PHP应用程序的工作负载

    文章来源:PHP开发学习门户 地址:http://www.phpthinking.com/archives/518 虽然一个 Web 应用程序的大部分内容都与表示有关,但它的价值与竞争优势却可能体如今 ...