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:跟随用户的位置和角度移动

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

 

转载于:https://www.cnblogs.com/Ager/p/4986343.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值