前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >iOS关于地图定位基础(二)[通俗易懂]

iOS关于地图定位基础(二)[通俗易懂]

作者头像
全栈程序员站长
发布于 2022-09-17 06:56:02
发布于 2022-09-17 06:56:02
1K00
代码可运行
举报
运行总次数:0
代码可运行

大家好,又见面了,我是你们的朋友全栈君。

在前一篇文章 iOS关于地图定位基础(一) 中我们主要总结了 iOS 里面利用原生 CoreLocation 框架实现基本定位功能和一些注意点,侧重点主要是iOS8+之后的定位授权与授权状态的使用。接下来本篇文章主要是讲解如何利用 CoreLocation 框架实现地理定位、区域监听、地理编码的具体实现。(PS:下文涉及我自定义的指南针Demo请去我的GitHub仓库查看源码https://github.com/IMLoser/HWCompass,谢谢大家支持。)

一、定位实现&监听方向)那么我们先来看看这个代理方法:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
// 通过位置管理者一旦定位到位置,就会一直调用这个代理方法
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations;

在这个方法中共有两个参数,一个是位置管理者,另一个就是保存有位置对象(CLLocation)的数组,这个数组中位置对象的存放顺序是按照时间排序的,那么最新的定位信息永远是数组最后一个元素。那么 CLLocation 对象又是什么呢?我们看看以下代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
    
    CLLocation * location = [locations lastObject];
    
    /*
     
     CLLocation 位置对象的重要属性:
     
     coordinate 定位到的经纬度坐标
     altitude 海拔
     horizontalAccuracy 水平精确度
     verticalAccuracy 垂直精确度
     course 航向(取值0 ~ 359.9)
     speed 速度
     
     */
    
}

光看干巴巴的属性来学习始终不够形象,下面我们来看个小案例 : 显示用户每次行走的方向和角度以及针对于上一次定位行走的距离,如 : 北偏东 30度 移动了12米。代码如下 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
{
    // 记录上一次位置
    CLLocation *_oldLocation;
}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#pragma mark - CLLocationManagerDelegate- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {        CLLocation * location = [locations lastObject];    NSString * locationInfo = nil;    NSInteger direction = (NSInteger)location.course / 90;        // 获取方向    switch (direction) {        case 0:            locationInfo = @"北偏东";            break;                    case 1:            locationInfo = @"东偏南";            break;                    case 2:            locationInfo = @"南偏西";            break;                    case 3:            locationInfo = @"西偏北";            break;                    default:            break;    }            // 获取角度    NSInteger angle = (NSInteger)location.course % 90;    if (!angle) {                locationInfo = [NSString stringWithFormat:@"正%@", [locationInfo substringToIndex:1]];            } else {        locationInfo = [locationInfo stringByAppendingString:[NSString stringWithFormat:@"%zd度", angle]];    }            // 获取移动的距离    NSInteger distance = 0;    if (_oldLocation) {        distance = [location distanceFromLocation:_oldLocation];    }    _oldLocation = location;            // 拼接打印    locationInfo = [locationInfo stringByAppendingString:[NSString stringWithFormat:@"移动了%zd米", distance]];    NSLog(@"%@", locationInfo);}

我们不仅可以获取用户的位置信息,也可以获取用户的方向信息。这里可以简单的制作一个指南针控件,废话不多讲,我们先来看看效果图:

必须提一下的是,想要实现这个效果模拟器就有些力不从心,所以在运行效果Demo的时候我选择了真机。。。核心代码如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import <UIKit/UIKit.h>

@interface HWCompass : UIView

// 获得指南针
+ (instancetype)getCompass;

// 开始获取方向
- (void)startUpdateHeading;

@end
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import "HWCompass.h"
#import <CoreLocation/CoreLocation.h>

@interface HWCompass () <CLLocationManagerDelegate>

/** 指南针视图 */
@property (nonatomic, weak) UIImageView * compassView;

/** 定位管理者 */
@property (strong, nonatomic) CLLocationManager * clManager;

@end

@implementation HWCompass

#pragma mark - lazy
- (CLLocationManager *)clManager
{
    if (!_clManager) {
        _clManager = [[CLLocationManager alloc] init];
        _clManager.delegate = self;
        
        if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
            [_clManager requestAlwaysAuthorization];
        }
        
        if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
            [_clManager allowsBackgroundLocationUpdates];
        }
        
    }
    return _clManager;
}

+ (instancetype)getCompass
{
    HWCompass * compass = [[HWCompass alloc] init];
    compass.backgroundColor = [UIColor clearColor];
    return compass;
}

- (void)startUpdateHeading
{
    [self.clManager startUpdatingHeading];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self initailSetting];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self initailSetting];
}

- (void)initailSetting
{
    UIImageView * compassView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"compass"]];
    _compassView = compassView;
    [self addSubview:compassView];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        // 长宽相等
        CGRect tmpFrame = self.frame;
        tmpFrame.size.height = tmpFrame.size.width;
        self.frame = tmpFrame;
        
        // 设置指南针视图
        _compassView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        
    });
}

#pragma mark - CLLocationManagerDelegate

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {

    [UIView animateWithDuration:0.1 animations:^{
        _compassView.transform = CGAffineTransformMakeRotation(M_PI * 2 - M_PI / 180 * newHeading.magneticHeading);
    }];
}

@end

以上这个是我自定义的指南针控件的代码,下面是控制器中的调用操作。。。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import "ViewController.h"
#import "HWCompass.h"

@interface ViewController ()

/**
 *  指南针
 */
@property (nonatomic, weak) HWCompass * compass;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    // 设置背景颜色
    self.view.backgroundColor = [UIColor blackColor];
    
    // 创建指南针控件
    HWCompass * compass = [HWCompass getCompass];
    _compass = compass;
    compass.frame = CGRectMake(0, 0, 200, 200);
    compass.center = CGPointMake(self.view.bounds.size.width * 0.5, self.view.bounds.size.height * 0.5);
    [self.view addSubview:compass];
    
}

// 点击启动指南针功能
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
    [_compass startUpdateHeading];
}

@end

二、区域监听)接下来我们来聊聊利用CoreLocation 框架实现简单的区域监听。这里需要补充的是在制作指南针的时候其实是没有必要申请用户授权的,因为获取方向不会涉及到用户隐私问题。但是用到区域监听功能时和定位的用户授权则是一样的。用到的核心类还是定位管理者CLLocationManager,懒加载创建、设置代理、授权都和定位功能实现是一样的;但是开启区域监听的方法、调用的代理确有些不同,具体代码实现如下 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> @interface ViewController () <CLLocationManagerDelegate> /** 定位管理者 */ @property (strong, nonatomic) CLLocationManager * clManager; @end @implementation ViewController - (CLLocationManager *)clManager { if (!_clManager) { _clManager = [[CLLocationManager alloc] init]; // 设置代理 _clManager.delegate = self; // 获取授权 if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { // 获取前后台授权 [_clManager requestAlwaysAuthorization]; } } return _clManager; } // 点击屏幕开启区域监听 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { // 要监听圆形区域A的中心点 CLLocationCoordinate2D centerA = CLLocationCoordinate2DMake(42.22, 121.11); // 设定监控的区域A CLCircularRegion * regionA = [[CLCircularRegion alloc] initWithCenter:centerA radius:1000 identifier:@"区域A"]; // 开始区域监听区域A [self.clManager startMonitoringForRegion:regionA]; // 要监听圆形区域B的中心点 CLLocationCoordinate2D centerB = CLLocationCoordinate2DMake(22.22, 80.11); // 设定监控的区域B CLCircularRegion * regionB = [[CLCircularRegion alloc] initWithCenter:centerB radius:1000 identifier:@"区域B"]; // 开始区域监听区域B [self.clManager startMonitoringForRegion:regionB]; } #pragma mark - CLLocationManagerDelegate // 已经进入到监控的区域 - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"进入区域%@", region.identifier); } // 已经离开监听的区域 - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@"离开区域%@", region.identifier); } @end

当我们视图更改模拟器坐标时,对应代理方法会针对是否进入或离开某个区域进行调用,具体打印如下 :

这里还有一个知识点的补充,我们还可以监听是否进入区域的状态,调用CLLocationManager 的实例方法 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 // 开始区域监听区域A // [self.clManager startMonitoringForRegion:regionA]; // 监听是否进入指定区域的状态(以上开启区域监听方法不调用亦可) [self.clManager requestStateForRegion:regionA];

实现对应的监听区域状态代理方法 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region; - (void)locationManager:(CLLocationManager *)manager     didEnterRegion:(CLRegion *)region; - (void)locationManager:(CLLocationManager *)manager     didExitRegion:(CLRegion *)region; 

具体代码实现如下 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> @interface ViewController () <CLLocationManagerDelegate> /** 定位管理者 */ @property (strong, nonatomic) CLLocationManager * clManager; @end @implementation ViewController - (CLLocationManager *)clManager { if (!_clManager) { _clManager = [[CLLocationManager alloc] init]; // 设置代理 _clManager.delegate = self; // 获取授权 if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { // 获取前后台授权 [_clManager requestAlwaysAuthorization]; } } return _clManager; } // 点击屏幕开启区域监听 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { // 要监听圆形区域A的中心点 CLLocationCoordinate2D centerA = CLLocationCoordinate2DMake(42.22, 121.11); // 设定监控的区域A CLCircularRegion * regionA = [[CLCircularRegion alloc] initWithCenter:centerA radius:1000 identifier:@"区域A"]; // 开始区域监听区域A // [self.clManager startMonitoringForRegion:regionA]; // 监听是否进入指定区域的状态(以上开启区域监听方法不调用亦可) [self.clManager requestStateForRegion:regionA]; } #pragma mark - CLLocationManagerDelegate // 已经进入到监控的区域 - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"进入%@", region.identifier); } // 已经离开监听的区域 - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@"离开%@", region.identifier); } // 监听区域状态的改变 - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region { switch (state) { case 0: NSLog(@"未知的state"); break; case 1: NSLog(@"进入区域state"); break; case 2: NSLog(@"离开区域state"); break; default: break; } } @end

三、地理编码&反编码)最后我们聊聊地理编码和反编码,用到的核心类是CoreLocation 框架中的CLGeocoder(编码器),所谓地理编码简单点讲就是把地名转换为坐标(经纬度),那相反的把地理左边转换为地名等等就叫做地理反编码了。此外还要接触一个新类CLPlacemark。我们先来看下案例的效果图 :

具体代码如下 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> @interface ViewController () /** 地理编码器 */ @property (strong, nonatomic) CLGeocoder * geocoder; @property (weak, nonatomic) IBOutlet UITextView *clInfoName; @property (weak, nonatomic) IBOutlet UITextField *clLatitude; @property (weak, nonatomic) IBOutlet UITextField *clLongitude; @end @implementation ViewController #pragma mark - lazy - (CLGeocoder *)geocoder { if (!_geocoder) { _geocoder = [[CLGeocoder alloc] init]; } return _geocoder; } // 地理编码 - (IBAction)geoClick { _clLatitude.text = @"查询中..."; _clLongitude.text = @"查询中..."; [self.geocoder geocodeAddressString:_clInfoName.text completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) { if (error) { _clLatitude.text = @"未查到"; _clLongitude.text = @"未查到"; return; } CLPlacemark * firstPlacemark = placemarks.firstObject; _clLatitude.text = [NSString stringWithFormat:@"%.2f", firstPlacemark.location.coordinate.latitude]; _clLongitude.text = [NSString stringWithFormat:@"%.2f", firstPlacemark.location.coordinate.longitude]; }]; } // 地理反编码 - (IBAction)reverseGeoClick { _clInfoName.text = @"查询中..."; CLLocation * location = [[CLLocation alloc] initWithLatitude:[_clLatitude.text doubleValue] longitude:[_clLongitude.text doubleValue]]; [self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) { if (error) { _clInfoName.text = @"未查询到"; return; } CLPlacemark * firstPlacemark = placemarks.firstObject; _clInfoName.text = firstPlacemark.locality; }]; } - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self.view resignFirstResponder]; _clInfoName.text = @""; _clLatitude.text = @""; _clLongitude.text = @""; } @end

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/158793.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
地图相关 CoreLocation框架介绍请求用户授权方法CLLocationManager 属性和方法CLLocation 位置对象介绍三、地理编码的实现
介绍 1.导入主头文件 #import <CoreLocation/CoreLocation.h> 2.地图和定位功能基于2个框架进行开发: (1)Map Kit :用于地图展示 (2)CoreLocation:用于地理定位,有时只用定位,比如外卖,只有需要显示地图才用map kit 3.2个热门专业术语: (1)LBS :Location Based Service 位置服务,又称定位服务 LBS的服务归纳为四类:定位(个人位置定位)、导航(路径导航)、查询(查询某个人或某个对象)、识别(识别某个
用户2141756
2018/05/18
1.8K0
iOS开发-用户定位获取-CoreLocation的实际应用-CLLocationManger获取定位权限-CLLocation详细使用方式
iOS提供了两个框架用来定位以及地图显示。CoreLocation框架包含的类可以帮助设备确定位置和航向以及使用基于位置的有效信息。MapKit框架未定位提供了户用页面的支持(地图显示),里面包含了地图视图、卫星地图视图以及2D、3D混合视图,并且能够让开发人员管理地图标注和地图覆盖层,前者 用于标注地点(常见的地图大头针),后者用来突出某区域或者路线等。
全栈程序员站长
2022/09/17
4.5K0
iOS开发-用户定位获取-CoreLocation的实际应用-CLLocationManger获取定位权限-CLLocation详细使用方式
iOS开发之定位
在iOS开发中,定位是很多App都需要使用的功能。本文主要对iOS中的定位知识点进行介绍。本文代码环境为:Xcode 10.1 + Swift 4.2。
YungFan
2019/03/21
1.6K0
iOS开发之定位
IOS 定位CoreLocation代码
定位需要使用苹果官方的类库CoreLocation,通过GPS来确定位置信息 并且需要实现CLLocationManagerDelegate协议 1.首先添加类库CoreLocation
用户8671053
2021/10/29
5740
iOS的MVC框架之模型层的构建
这篇文章是论MVVM伪框架结构和MVC中M的实现机制的姊妹篇。在前面的文章中更多介绍的是一些理论性质的东西,一些小伙伴在评论中也说希望有一些具体设计实践的例子,以及对一些问题进行了更加深入的交流讨论,因此准备了这篇文章。这篇文章将更多的介绍如何来进行模型层构建。
欧阳大哥2013
2018/08/22
9190
iOS的MVC框架之模型层的构建
iOS区域监控(地理围栏)
区域监控,高德地图上叫地理围栏,两者都是同一个意思。此功能实现的是:首先创建一个区域(围栏),当用户设备进入或者离开此区域时,会有相应的代理方法响应,开发者可以做一些操作。并且最重要的一点是当开启了区域监控,即使用户杀死了APP还是可以监听到代理方法的响应,从而做一些操作。
用户6094182
2019/08/23
1.6K0
iOS区域监控(地理围栏)
疯狂ios讲义之使用CoreLocati
9.3  方向监测 拥有GPS硬件的设备可以生成设备的当前方向(course属性)和速度信息。iPhone设备携带的定位管理器可以返回一个已经计算好的course值,通过这个值我们可以获得当前前进的方向,course值是0~360之间的浮点数,0°值表示正北方向,90°值表示正东方向,180°值表示正南方向,270°值表示正西方向,程序可以通过course值来检测用户位置的移动方向。除此之外,还可以通过磁力计来获取设备的真实方向。 提示:
py3study
2020/01/08
8580
疯狂ios讲义之使用CoreLocati
iOS开发之地图与定位
  无论是QQ还是微信的移动客户端都少不了定位功能,之前在微信demo中没有添加定位功能,今天就写个定位的小demo来了解一下定位和地图的东西。地图和定位看上去是挺高大上一东西,其实用法比TableView简单多了,下面的Demo是用的iOS中自带的地图和定位,当然了也可以用第三方的来加载地图,比如百度地图啥的,在这就不赘述了。今天的博客主要是介绍MKMapView的使用,MapView的使用和其他组件的用法差不多,MapView用的是委托回调,在使用mapView的Controller中要实现MKMapV
lizelu
2018/01/11
1.5K0
iOS开发之地图与定位
IOS 定位CoreLocation
import CoreLocation 2 class ViewController:UIViewController,CLLocationManagerDelegate 3 var locationManager:CLLocationManager! 4 var label:UILabel! 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 // Do any additional setup after loading the view, typically from a nib. 8 9 locationManager = CLLocationManager() 10 locationManager.delegate = self 11 locationManager.desiredAccuracy = kCLLocationAccuracyBest 12 locationManager.distanceFilter = 1000.0 13 14 label = UILabel(frame:CGRect(x:20, y:80, width: 280, height:100)) 15 label.numberOfLines = 2 16 label.backgroundColor = UIColor.brown 17 self.view.addSubview(label) 18 19 if CLLocationManager.authorizationStatus() == .notDetermined { 20 locationManager.requestAlwaysAuthorization() 21 } 22 } 23 func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { 24 switch status { 25 case .denied: 26 print(“用户拒绝您对地理设备使用的请求。”) 27 break; 28 default: 29 manager.startUpdatingLocation() 30 break; 31 } 32 } 33 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 34 locationManager.stopUpdatingLocation() 35 36 let location:CLLocation = locations[0] 37 let latitude = location.coordinate.latitude 38 let longitude = location.coordinate.longitude 39 40 label.text = “经度:(longitude)\n 纬度:(latitude)” 41 }
用户5760343
2019/07/10
4430
iOS-世界那么大,CoreLocation带你去看看
一. 简介 在我们日常生活中时常用到地图和定位功能,来导航去你想去的地方或者寻找周边的景点,餐厅,电影院等等,在iOS开发中,要想加入这两大功能,必须基于两个框架进行开发,有了这两个框架,想去哪就去哪。 CoreLocation :用于地理定位,地理编码,区域监听等(着重功能实现) MapKit :用于地图展示,例如大头针,路线、覆盖层展示等(着重界面展示) 二. CoreLocation框架的基本使用 1. CoreLocation使用步骤 导入CoreLocation框架。 创建CLLocation
xx_Cc
2018/05/10
1.4K0
【IOS开发基础系列】地图开发专题
http://www.cnblogs.com/syxchina/archive/2012/10/14/2723522.html
江中散人_Jun
2023/10/16
3770
【IOS开发基础系列】地图开发专题
iOS_系统自带地图圆形区域选择范围
5.聚集操作:删除原理的大头针,在新经纬度添加大头针,并将地图移动到新的经纬度(反地理编码获得位置信息)
mikimo
2022/07/20
2.3K0
iOS_系统自带地图圆形区域选择范围
iOS定位--CoreLocation框架
CoreLocation框架的使用 // 首先导入头文件 #import <CoreLocation/CoreLocation.h> CoreLocation框架中所有数据类型的前缀都是CL CoreLocation中使用CLLocationManager对象来做用户定位 1.CLLocationManager的使用 CLLocationManager的常用操作 /** * 定位管理者,全局变量强引用,防止销毁 */ @property (nonatomic ,strong) CLLocationMa
用户1941540
2018/05/11
1.9K0
IOS定位服务的应用 原
在IOS8之后,IOS的定位服务做了优化,若要使用定位服务,必须先获取用户的授权。
珲少
2018/08/15
8850
IOS定位服务的应用
                                                                            原
iOS 8 实现获取当前定位信息
// // ViewController.m // LocationDemo // // Created by LaughingZhong on 14/11/12. // Copyright (c) 2014年 Laughing. All rights reserved. // import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize myLocatio
大师级码师
2021/10/29
4520
iOS-CoreLocation框架的定位和逆地址解析详解
一、权限问题 在iOS8以后,应用定位需要获取用户授权,我们可以请求的定位权限有两种: 1.仅在使用时定位requestWhenInUseAuthorization(应用在前台才能定位); 2.始
用户2215591
2018/06/29
1.3K0
iOS开发之地图
在iOS开发中,地图也是很多App都需要使用的功能。本文主要对iOS中的地图知识点进行介绍。需要说明的是地图看似很复杂,其实它仅仅是一个控件,就和UIButton、UITableView等一样。本文代码环境为:Xcode 10.2。
YungFan
2019/05/10
1.2K0
iOS开发之地图
iOS地理围栏技术的应用
遇到一个需求,要求监测若干区域,设备进入这些区域则要上传数据,且可以后台监测,甚至app被杀死也要监测。发现oc的地理围栏技术完美匹配这个需求,任务做完了,把遇到的坑记录下来,也许能帮到你呢。 要做这个需求,我们需要把任务分成两大块,一块是支持后台监测且app被杀掉也要持续监测,另一块是如何进行区域监测。 而区域监测我们有3种方法完成: 1,oc自有的,利用CLLocationManager监测若干CLCircularRegion区域 2,高德地图旧版地理围栏,利用AMapLocationManager监测
王大锤
2018/05/17
2.1K0
iOS14开发-定位与地图
CoreLocation 是 iOS 中用于设备定位的框架。通过这个框架可以实现定位进而获取位置信息如经度、纬度、海拔信息等。
YungFan
2021/07/14
2.5K0
iOS8新特性之基于地理位置的消息通知UILocalNotification
iOS8中更新和公开了非常多接口,当中有一项本地消息通知UILocalNotification,大家肯定都不陌生。
全栈程序员站长
2022/07/10
4200
iOS8新特性之基于地理位置的消息通知UILocalNotification
相关推荐
地图相关 CoreLocation框架介绍请求用户授权方法CLLocationManager 属性和方法CLLocation 位置对象介绍三、地理编码的实现
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文