星空网 > 软件开发 > 操作系统

CoreLocation MKMapView 地图

系统自带地图  框架: CoreLocation MapKit

CLLocationManager --> 定位管理者  CLGeocoder --> 地理编码器 MKMapView --> 地图view

允许用户定位
    [_locationManager requestAlwaysAuthorization];//总是允许
    [_locationManager requestWhenInUseAuthorization];//用户用时允许

用户移动100米的时候才会再次调用位置代理方法
    _locationManager.distanceFilter = 100.0;

开始定位

  [_locationManager startUpdatingLocation];

CLLocationManager 代理方法:(获取到信息室处理)

  - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
  }

创建比例系数  显示在哪个点上
   MKCoordinateRegion region = MKCoordinateRegionMake(userLocation.coordinate, MKCoordinateSpanMake(0.1, 0.1));
   比例系数赋值
   _mapView.region = region;


CLGeocoder:

编码:提供某个字符串 来定位位置:- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;

反编码:根据位置显示该地方的名字等等[_geocoder reverseGeocodeLocation:placemark.location  completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {}];

添加大头针:

  AGAnnotion *agAnnotion = [[AGAnnotion alloc]init];
    agAnnotion.coordinate = CLLocationCoordinate2DMake(36.0, 120.0);
    agAnnotion.title = @"coco";
    [_mapView addAnnotation:agAnnotion];
自定义气泡

  继承 NSObject , 遵守 MKAnnotation 协议

  创建三个属性

  @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
  @property (nonatomic, copy) NSString *title;
  @property (nonatomic, copy) NSString *subtitle;

 高德:

 1. 验证key
    [MAMapServices sharedServices].apiKey = @“申请的key”;
 2. 初始化
    mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.bounds))];
    mapView.delegate = self;
    mapView.language = MAMapLanguageEn; // 设置地图显示语言
    mapView.mapType = MAMapTypeStandard; // 地图类型
    /*
     MAMapTypeSatellite:卫星地图
     MAMapTypeStandard:标准地图
     */

    mapView.showTraffic = YES; // 显示实时交通路况
    [self.view addSubview:mapView];
    mapView.showsUserLocation = YES;

mapView的定位模式: userTrackingMode

  MAUserTrackingModeNone:不跟随用户位置,仅在地图上显示。

  MAUserTrackingModeFollow:跟随用户位置移动,并将定位点设置成地图中心点

  MAUserTrackingModeFollowWithHeading:跟随用户的位置和角度移动

系统的地图和 高德地图 的区别

 




原标题:CoreLocation MKMapView 地图

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

物流行业如何打破老旧思维做好线上营销?:https://www.goluckyvip.com/news/3501.html
为什么我的产品老是审核不通过?Lazada产品审核拒绝原因:https://www.goluckyvip.com/news/3502.html
东南亚电商9.9大促11天作战指南第一天:https://www.goluckyvip.com/news/3503.html
东南亚跨境电商的风倒是吹起来了!:https://www.goluckyvip.com/news/3504.html
TikTok的最后48小时,中国出手了!:https://www.goluckyvip.com/news/3505.html
TikTok Shop美国站“TushBaby臀带”日售5500单,两周卖出140万美金 | 嘀嗒狗:https://www.goluckyvip.com/news/35055.html
深圳大湾区游轮夜景 深圳大湾区游轮夜景图:https://www.vstour.cn/a/363186.html
美国圣地亚哥旅游攻略:圣地亚哥必去旅游景点:https://www.vstour.cn/a/363187.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流