zoukankan      html  css  js  c++  java
  • IOS 地图的开发(coreLocation)

    概述

    API

    大框架

    • CoreLocation:用于地理定位,地理编码区域监听等(着重功能实现)
    • MapKit:用于地图展示,例如大头针,路线,覆盖层展示等(着重界面展示)

    内部的框架

    • CoreLocation框架

      • CoreLocation
      • CLLocation
      • ios地图开发的隐私保护(如何添加授权)
      • CLGeocoder
      • CLPlacemark
    • MapKit框架

      • MKMapView
      • MKCoordinateRegion
      • MKMapView的代理
      • MKUserLocation
      • 大头针
      • annotation
      • 自定义大头针
      • MKAnnotationView
      • MKPinAnnotationView
      • MKMapItem调用系统APP进行导航
      • MKMapCamera地图街景
      • MKMapSnapshotter地图截图

    常用的类和方法

    CLLocationManager

    CLLocation

    CLLocationCoordinate2D

    CLGeocoder

    CLPlacemark

    CLLocationManager

    • CoreLocation框架中使用CLLocationManager对象来做用户定位
    • 创建(初始化)
    CLLocationManager *lM = [[CLLocationManager alloc] init];

    1.manager设置定位的精准度(最优的方式,导航最好的方式,10m,100m等等),定位越远,好点越多

    2.manager取出授权(authorizationStatus),没有授权,先授权。

    3.manager使用startUpdating开启定位

    4.使用didiupdating回调确认定位

    5.使用(didChangeAuthorizationStatus)确认授权信息

    CLLocation

    使用属性(coordinate)获取经度,纬度,航向,海拔,速度

    CLLocationCoordinate2D

    里面包含经度,纬度,航向,海拔,速度信息

    CLGeocoder

    • 地理编码方法-(void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;
    • 反地理编码方法-(void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler;
    [self.geoC geocodeAddressString:self.addressDetailTV.text completionHandler:^(NSArray<CLPlacemark *> * __nullable placemarks, NSError * __nullable error) {
            // 包含区,街道等信息的地标对象
            CLPlacemark *placemark = [placemarks firstObject];
            // 城市名称
    //        NSString *city = placemark.locality;
            // 街道名称
    //        NSString *street = placemark.thoroughfare;
            // 全称
            NSString *name = placemark.name;
            self.addressDetailTV.text = [NSString stringWithFormat:@"%@", name];
            self.latitudeTF.text = [NSString stringWithFormat:@"%f", placemark.location.coordinate.latitude];
            s
    }
    [self.geoC reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * __nullable placemarks, NSError * __nullable error) {
            // 包含区,街道等信息的地标对象
            CLPlacemark *placemark = [placemarks firstObject];
            // 城市名称
    //        NSString *city = placemark.locality;
            // 街道名称
    //        NSString *street = placemark.thoroughfare;
            // 全称
            NSString *name = placemark.name;
            self.addressDetailTV.text = [NSString stringWithFormat:@"%@", name];
        }];

    CLPlacemark

    • @property (nonatomic, readonly) CLLocation *location;地理位置
    • @property (nonatomic, readonly) CLRegion *region;
      区域
    • @property (nonatomic, readonly) NSDictionary *addressDictionary;详细的地址信息
    • @property (nonatomic, readonly) NSString *name;
      地址名称
    • @property (nonatomic, readonly) NSString *locality;
      城市
  • 相关阅读:
    MFC学习篇(二):error LNK2005 及其解决方法
    MFC学习篇(一):用OpenCV显示视频
    记一次mysql安装!
    常用数据对应关系及简单介绍
    docker
    月份及星期 缩写
    java 面对对象笔记
    linux小案例 定时备份数据库
    rpm_yum_开发工具的安装
    shell入门
  • 原文地址:https://www.cnblogs.com/guchengfengyun/p/8128020.html
Copyright © 2011-2022 走看看