7.3 Pinpointing the Location of a Device

2024-03-01 10:18

本文主要是介绍7.3 Pinpointing the Location of a Device,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


定位

.h文件

#import <UIKit/UIKit.h>

#import <CoreLocation/CoreLocation.h>


@interface ViewController : UIViewController<CLLocationManagerDelegate>


@end




.m文件

#import "ViewController.h"


@interface ViewController ()

@property (nonatomic, strong) CLLocationManager *myLocationManager;


@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

    if ([CLLocationManager locationServicesEnabled]){

        self.myLocationManager = [[CLLocationManager alloc] init];

        self.myLocationManager.delegate = self;

//      self.myLocationManager.purpose =@"To provide functionality based on user's current location.";

        [self.myLocationManager startUpdatingLocation];

    } else {

        /* Location services are not enabled.

         Take appropriate action: for instance, prompt the user to enable location services */

        NSLog(@"Location services are not enabled");

    }


}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


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

           fromLocation:(CLLocation *)oldLocation{ /* We received the new location */

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

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

}


- (void)locationManager:(CLLocationManager *)manager

       didFailWithError:(NSError *)error{

    /* Failed to receive user's location */

    NSLog(@"error = %@",error);

}



@end


输出:

2014-04-04 15:16:19.156 cookbook[2295:907] Latitude = 24.485830

2014-04-04 15:16:19.160 cookbook[2295:907] Longitude = 118.182506

2014-04-04 15:16:19.170 cookbook[2295:907] Latitude = 24.485830

2014-04-04 15:16:19.173 cookbook[2295:907] Longitude = 118.182506

2014-04-04 15:16:19.382 cookbook[2295:907] Latitude = 24.485870

2014-04-04 15:16:19.384 cookbook[2295:907] Longitude = 118.182481

2014-04-04 15:16:19.950 cookbook[2295:907] Latitude = 24.485832

2014-04-04 15:16:19.951 cookbook[2295:907] Longitude = 118.182477

这篇关于7.3 Pinpointing the Location of a Device的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/762093

相关文章

Nginx Location映射规则总结归纳与最佳实践

《NginxLocation映射规则总结归纳与最佳实践》Nginx的location指令是配置请求路由的核心机制,其匹配规则直接影响请求的处理流程,下面给大家介绍NginxLocation映射规则... 目录一、Location匹配规则与优先级1. 匹配模式2. 优先级顺序3. 匹配示例二、Proxy_pa

Nginx location匹配模式与规则详解

《Nginxlocation匹配模式与规则详解》:本文主要介绍Nginxlocation匹配模式与规则,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、环境二、匹配模式1. 精准模式2. 前缀模式(不继续匹配正则)3. 前缀模式(继续匹配正则)4. 正则模式(大

解决SpringBoot启动报错:Failed to load property source from location 'classpath:/application.yml'

《解决SpringBoot启动报错:Failedtoloadpropertysourcefromlocationclasspath:/application.yml问题》这篇文章主要介绍... 目录在启动SpringBoot项目时报如下错误原因可能是1.yml中语法错误2.yml文件格式是GBK总结在启动S

详解nginx 中location和 proxy_pass的匹配规则

《详解nginx中location和proxy_pass的匹配规则》location是Nginx中用来匹配客户端请求URI的指令,决定如何处理特定路径的请求,它定义了请求的路由规则,后续的配置(如... 目录location 的作用语法示例:location /www.chinasem.cntestproxy

Nginx配置location+rewrite实现隐性域名配置

《Nginx配置location+rewrite实现隐性域名配置》本文主要介绍了Nginx配置location+rewrite实现隐性域名配置,包括基于根目录、条件和反向代理+rewrite配置的隐性... 目录1、配置基于根目录的隐性域名(就是nginx反向代理)2、配置基于条件的隐性域名2.1、基于条件

Nginx中location实现多条件匹配的方法详解

《Nginx中location实现多条件匹配的方法详解》在Nginx中,location指令用于匹配请求的URI,虽然location本身是基于单一匹配规则的,但可以通过多种方式实现多个条件的匹配逻辑... 目录1. 概述2. 实现多条件匹配的方式2.1 使用多个 location 块2.2 使用正则表达式

GNSS CTS GNSS Start and Location Flow of Android15

目录 1. 本文概述2.CTS 测试3.Gnss Flow3.1 Gnss Start Flow3.2 Gnss Location Output Flow 1. 本文概述 本来是为了做Android 14 Gnss CTS 的相关环境的搭建和测试,然后在测试中遇到了一些问题,去寻找CTS源码(/cts/tests/tests/location/src/android/locat

web群集--nginx配置文件location匹配符的优先级顺序详解及验证

文章目录 前言优先级顺序优先级顺序(详解)1. 精确匹配(Exact Match)2. 正则表达式匹配(Regex Match)3. 前缀匹配(Prefix Match) 匹配规则的综合应用验证优先级 前言 location的作用 在 NGINX 中,location 指令用于定义如何处理特定的请求 URI。由于网站往往需要不同的处理方式来适应各种请求,NGINX 提供了多种匹

Usb Audio Device Descriptor(10) Hid Device

对于 Standard Interface Descriptor, 当 bInterfaceClass=0x03时,即为HID设备。Standard Interface Descriptor如下 struct usb_standard_interface_descriptor{U8 bLength; /*Size of this descriptor in bytes*/U8 bDescrip

src/pyaudio/device_api.c:9:10: fatal error: portaudio.h: 没有那个文件或目录

(venv) shgbitai@shgbitai-C9X299-PGF:~/pythonworkspace/ai-accompany$ pip install pyaudio sounddeviceCollecting pyaudioDownloading PyAudio-0.2.14.tar.gz (47 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━