iOS系统高德地图的使用

重要的写在前面,整理了一下系统高德地图的一般使用,相关demo请点击demo链接 ,已经更新了Swift版本。

1. 地图(MKMapView)的使用

self.mapView.mapType =  MKMapTypeStandard;

//显示指南针

self.mapView.showsCompass = YES;

//显示比例尺

self.mapView.showsScale = YES;

//显示用户所在的位置

self.mapView.showsUserLocation = YES;

self.mapView.delegate =self;

[self.view addSubview:self.mapView];

#pragma mark -  地图代理方法有

//一个位置更改默认只会调用一次,不断监测用户的当前位置//每次调用,都会把用户的最新位置(userLocation参数)传进来

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{

}

//地图的显示区域即将发生改变的时候调用

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated{    }

//地图的显示区域已经发生改变的时候调用

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{    }//设置大头针- (nullable MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation{

}

2. 定位(CLLocationManager)的使用

if ( [CLLocationManager  locationServicesEnabled]) {

NSLog(@"可以定位");

self.locationManager = [[CLLocationManager alloc]init];

self.locationManager.delegate = self;

//设置定位精度

self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;

//设置距离

self.locationManager.distanceFilter = 50;

//申请定位许可,iOS8以后特有

if([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {

[self.locationManager requestWhenInUseAuthorization];

}

//开始定位

[self.locationManager startUpdatingLocation];

}else{

NSLog(@"请打开定位权限");

}

#pragma mark - 定位代理方法//locationManager:didUpdateLocations:(调用很频繁)- (void)locationManager:(CLLocationManager *)manager    didUpdateLocations:(NSArray*)locations{

}

//定位失败

- (void)locationManager:(CLLocationManager *)manager  didFailWithError:(NSError *)error{

   NSLog(@"定位失败error%@",error);

}

//方向的更新

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

}

//用于判断是否显示方向的校对,用于判断是否显示方向的校对,返回yes的时候,将会校对正确之后才会停止

//或者dismissheadingcalibrationdisplay方法解除。

-(BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager{

return  YES;

}

3.自定义大头针
这里写图片描述

4.路线规划,画线
这里写图片描述

5.跳转第三方地图导航

需要注意要添加白名单这里写图片描述

6. 地理编码和反地理编码(CLGeocoder)的使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值