首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏全栈程序员必看

    CLLocation定位

    ) /// 定位 var locationManager: CLLocationManager = CLLocationManager() var currLocation: CLLocation locationManager.startUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation ]) { let location: CLLocation = locations.last! print(“didChangeAuthorization—\(status.rawValue)”) } func lonlatToCity(_ location: CLLocation

    84820编辑于 2022-09-17
  • 来自专栏iOSer

    iOS根据两点经纬度坐标计算指南针方位角

    目录 需求 设计 代码实现 新建CLLocation 分类方法 调用示例 结论 需求 在地图导航时,始终保持当前路段竖直超前。 设计 因地图暴露的方法中只有设置地图相对于正北的方向角的方法。 代码实现 新建CLLocation 分类方法 #import <CoreLocation/CoreLocation.h> + (double)ca_getCompassAngleFromCoor1:( toRadius:lat1]; double φ2 = [CLLocation toRadius:lat2]; double Δλ = [CLLocation toRadius:(long2 * cos(Δλ); double y = sin(Δλ) * cos(φ2); double θ = atan2(y, x); double bearing = [CLLocation ; } + (double)toRadius:(double)degree { return degree * M_PI / 180.0; } 调用示例 double bearing = [CLLocation

    48330编辑于 2023-01-13
  • 来自专栏DannyHoo的专栏

    iOS开发中使用百度地图计算两点间的距离

    在没找到该头文件前我本来是想放弃百度地图的这个方法而使用原生的方法的,原生的方法: CLLocation *location1 = [[CLLocation alloc] initWithLatitude :userLocation.location.coordinate.latitude longitude:userLocation.location.coordinate.longitude]; CLLocation *location2 = [[CLLocation alloc] initWithLatitude:model.latitude longitude:model.longitude] ; CLLocationDistance

    1.8K21发布于 2018-09-13
  • 来自专栏iOSer

    iOS根据两点经纬度坐标计算指南针方位角

    代码实现新建CLLocation 分类方法#import <CoreLocation/CoreLocation.h>+ (double)ca_getCompassAngleFromCoor1:(CLLocationCoordinate2D latitude; double long2 = coor2.longitude; double lat2 = coor2.latitude; double φ1 = [CLLocation toRadius:lat1]; double φ2 = [CLLocation toRadius:lat2]; double Δλ = [CLLocation toRadius:(long2 φ2) * cos(Δλ); double y = sin(Δλ) * cos(φ2); double θ = atan2(y, x); double bearing = [CLLocation / M_PI;}+ (double)toRadius:(double)degree { return degree * M_PI / 180.0;}调用示例double bearing = [CLLocation

    1.1K20编辑于 2023-01-10
  • 来自专栏iOS开发~

    iOS_系统自带地图圆形区域选择范围

    *currentloc = [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude ]; CLLocation *loc = [[CLLocation alloc] initWithLatitude:self.currentAnnotationView.annotation.coordinate.latitude pragma mark - 获得用户定位 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *loc = [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude]; [ reverseGeocodeWith:loc]; // 反地理编码 } #pragma mark - 反地理编码 (更新label text) - (void)reverseGeocodeWith:(CLLocation

    2.8K10编辑于 2022-07-20
  • 来自专栏全栈程序员必看

    iOS iOS 地图与定位开发系列教程

    iPhone SDK提供了三个类来管理位置信息:CLLocation CLLocationManager 和 CLLHeading(不常用)。 1、CLLocation CLLocation类代表一个位置信息,其中还包括了方向和速度。比如我在长安街188号以5公里/小时的速度往西走。 它的属性和方法有: @property CLLocation *location; //位置 @property id<CLLocationManagerDelegate> delegate; @property 这个类包含了多个属性:手机的位置(类型为CLLocation)、位置文字信息(类型为NSString)等。 MKPlacemark保存了位置(经纬度)和地址之间的映射。 设置经纬度 CLLocation *loc = [[CLLocation alloc]initWithLatitude:self.latitude longitude:self.longitude

    3.4K30编辑于 2022-09-17
  • 来自专栏ShaoYL

    iOS定位--CoreLocation框架

    对象 在startUpdatingLocation 代理方法中可以得到用户的坐标信息 // 1.获取最后一次的位置 CLLocation *location = [locations lastObject */ /* 可以设置模拟器模拟速度 bicycle ride 骑车移动 run 跑动 freeway drive 高速公路驾车 */ CLLocation *)location; // 北京:39.6 116.39 // 广州:23.08 113.15 CLLocation *BeiJing = [[CLLocation alloc ] initWithLatitude:39.6 longitude:116.39]; CLLocation *GuangZhou = [[CLLocation alloc] initWithLatitude CLLocation用来表示某个位置的地理信息,比如经纬度、海拔等等 // 属性 location.coordinate; 坐标, 包含经纬度 location.altitude;

    2.2K100发布于 2018-05-11
  • 来自专栏滕先生的博客

    地图相关 CoreLocation框架介绍请求用户授权方法CLLocationManager 属性和方法CLLocation 位置对象介绍三、地理编码的实现

    位置对象介绍 CLLocation用来表示某个位置的地理信息,比如经纬度、海拔等等,创建一个 CLLocation对象只需要两个参数:纬度和经度 属性: (1)2D位置坐标,经纬度 @property *location1 = [[CLLocation alloc] initWithLatitude:40.06 longitude:116.39]; CLLocation *location2 = [ *> *)locations{ //CLLocation 位置对象 --> 经纬度 //CLLocationCoordinate2D coordinate 经纬度 //获取最后一次位置信息 CLLocation *location = locations.lastObject; //输出纬度和经度 NSLog(@"latitude: %f,longitude: % 创建 CLLocation对象,输入经纬度信息 CLLocation *location = [[CLLocation alloc] initWithLatitude:[self.latitudeTF.text

    2.3K120发布于 2018-05-18
  • 来自专栏iOSer成长记录

    iOS-CoreLocation框架的定位和逆地址解析详解

    (WGS-84),或者叫GPS坐标 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation self.locationManager.delegate = nil // 停止定位 self.locationManager.stopUpdatingLocation() } 三、CLLocation -> CLLocationDistance 四、逆地址解析 我们使用CLGeocoder实现逆地址解析,而且非常简单,如下 func reverseGeocodeLocation(location:CLLocation 就会有问题,举例子来说明: func reverseGeocodeLocation(location:CLLocation){ 假设lacation参数是通过didUpdateLocations } } case2:如果此时我从新创建一个CLLocation,此时在iOS9上是没有问题的,但在其他iOS系统上,解析出来就会有很多误差,如下代码 let loc = CLLocation

    1.7K20发布于 2018-06-29
  • 来自专栏sktj

    IOS 定位CoreLocation

    31 } 32 } 33 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation ]) { 34 locationManager.stopUpdatingLocation() 35 36 let location:CLLocation = locations[0] 37 let

    53420发布于 2019-07-10
  • 来自专栏全栈程序员必看

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

    那么 CLLocation 对象又是什么呢? *> *)locations { CLLocation * location = [locations lastObject]; /* CLLocation )locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations { CLLocation * location = [locations lastObject]; NSString * locationInfo = nil; NSInteger "; CLLocation * location = [[CLLocation alloc] initWithLatitude:[_clLatitude.text doubleValue] longitude

    1.5K20编辑于 2022-09-17
  • 来自专栏全栈程序员必看

    iOS开发-用户定位获取-CoreLocation的实际应用-CLLocationManger获取定位权限-CLLocation详细使用方式

    本期内容: CLLocationManager申请定位权限 CLLocationManager获取用户定位 CLLocation详细使用,定位数据处理 GPX虚拟定位文件的使用以及模拟器定位使用 --- 具体实现如下: // 代理方法,更新位置 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{ // locations是一个数组提供了一连串的用户定位,所以在这里我们只取最后一个(当前最后的定位) CLLocation * newLocation CLLocation详细使用,定位数据处理 在上面我们看到了一个类:CLLocation。和CLLocationManager很像是吧? 官方有话说:CLLocation对象包含设备的地理位置和高度,以及指示这些测量值的准确性和收集时间的值。在iOS中,位置对象还包含航向信息,即设备移动的速度和方向。 那我们如何来获得这些信息呢?

    5.7K20编辑于 2022-09-17
  • 来自专栏码农的生活

    IOS 定位CoreLocation代码

    (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ for(CLLocation *loc in locations){ //CLLocation 就是一次经纬度 , 方向 海拔 等信息 //loc.coordinate就是取的经纬度

    81920发布于 2021-10-29
  • 来自专栏大宇笔记

    swift 定位封装一句话使用

    CoreLocation class LocationManager: NSObject { typealias locationCallBack = (_ curLocation:CLLocation //当前坐标 var curLocation: CLLocation? CLLocationManagerDelegate { func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation

    1.6K20发布于 2019-01-15
  • 来自专栏全栈程序员必看

    ios项目开发(天气预报项目):通过经纬度获取当前城市名称

    #import <CoreLocation/CLLocation.h> 2.#import <CoreLocation/CLLocationManager.h> 3. CLLocation *loc = [[CLLocation alloc]initWithLatitude:BJ_LATITUDE longitude:BJ_LONGITUDE]; 9. 10.

    91320编辑于 2022-07-11
  • 来自专栏码客

    iOS地图开发1-定位(swift)

    ."); if(locations.count>0){ var location:CLLocation = locations[locations.count-1] as! CLLocation if (location.horizontalAccuracy > 0) { self.locationManager.stopUpdatingLocation CLLocationCoordinate2D(latitude: latitude, longitude: longitude)) geocoder.reverseGeocodeLocation(CLLocation

    2K10发布于 2019-10-22
  • 来自专栏学海无涯

    iOS开发之集成高德地图(一)

    alloc]init]; //单次定位 [self.locationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation #pragma mark - 2个代理方法 - (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation - (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode

    2K60发布于 2018-05-03
  • 来自专栏iOSDevLog

    ARKit和CoreLocation:第三部分

    CoreLocation protocol LocationServiceDelegate: class { func trackingLocation(for currentLocation: CLLocation locationManager: CLLocationManager var delegate: LocationServiceDelegate var currentLocation: CLLocation () } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation updateLocationDidFailWithError(error: error as NSError) } func updateLocation(currentLocation: CLLocation

    1.4K20发布于 2018-09-20
  • 来自专栏全栈程序员必看

    iOS逆向入门实践 — 逆向微信,伪装定位(二)

    0.1 || lng < 0.1) { lat = 35.707013; lng = 139.730562; } CLLocation *tokyoLocation = [[CLLocation alloc] initWithLatitude:lat longitude:lng]; CLLocation *cantonLocation = [[CLLocation alloc] initWithLatitude:23.127444 longitude:113.257217]; #pragma clang diagnostic push

    1.8K30编辑于 2022-09-05
  • 来自专栏xx_Cc的学习总结专栏

    iOS-世界那么大,CoreLocation带你去看看

    代理方法didUpdateLocations会被持续调用,参数manager位置管理者 locations表示位置数组,里面按照时间先后顺序存储CLLocation对象,获取最后一个位置信息[locations 定位常用代理方法 // 定位成功 持续调用 -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation 对象 -- 定位基本属性 // 根据经度和维度创建一个CLLocation对象 - (instancetype)initWithLatitude:(CLLocationDegrees)latitude error指错误信息,如果错误error有值 CLPlacemark基本属性 // 对应的位置对象 参考CLLocation基本属性 @property (nonatomic, readonly, copy , nullable) CLLocation *location; @property (nonatomic, readonly, copy, nullable) CLRegion *region; /

    1.8K90发布于 2018-05-10
领券