高德开发者平台 有开发指南

iOS9配置网络:

<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>

请看这里  原文章:http://www.oschina.net/question/262659_149771?fromerr=Y0rzKueR

1. GPS定位:<CoreAudioKit/CoreAudioKit.h>

1. 基本属性:

1>

CLLocationManager:定位管理器   协议:<CLLocationManagerdelegate> 设置代理 实现方法

CLLocation:位置的具体信息(经纬度 等等)

CLHeading:设备移动方向

CLRegion:一个区域(常用子类:CLCircularRegion:圆形 CLBeaconRegion:蓝牙)

[CLLocationManager locationServicesEnabled] 定位服务是否可用

distanceFilter:自动过滤距离 移动某个距离之后重新调用代理方法 更新位置

desiredAccuracy:定位的精度

self.manager.desiredAccuracy = kCLLocationAccuracyBest; // 最佳精度
self.manager.pausesLocationUpdatesAutomatically = YES; // 不需要的时候可以自动暂停
- (void)viewDidLoad {
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self; // 允许定位
[self.locationManager requestAlwaysAuthorization]; // 自动过滤距离 移动100米之后重新调用代理方法 更新位置
self.locationManager.distanceFilter = 100.0; // 米为单位 // iOS7的系统下 写完start就可以开始定位了
[self.locationManager startUpdatingLocation]; // 初始化地理编码器:
self.geocoder = [CLGeocoder new];
}

2> CLGeocoder 地理编码器:

创建:

self.geocoder = [CLGeocoder new];

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

[self.geocoder geocodeAddressString:self.inputLocation.text completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
// 取出一个位置信息
CLPlacemark *placeMark = placemarks.lastObject;
// 输出信息
NSLog(@"%lf %lf", placeMark.location.coordinate.latitude, placeMark.location.coordinate.longitude);
}];

反编码:根据位置显示该地方的名字等等

[self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
CLPlacemark *place = placemarks.lastObject;
self.inputLocation.text = place.name;
NSLog(@" %@",place.name);
}];

2. 获取位置信息:

iOS7的系统下 写完start就可以开始定位了:

[self.locationManager startUpdatingLocation];

但是在iOS之后就需要设置是否允许定位:设置完成这个之后才可以定位

requestAlwaysAuthorization:一直允许定位

requestWhenInUseAuthorization:用户允许

在添加之前需要在info.plist 文件中添加字段:NSLocationAlwaysUsageDescription  (后面的字符串知识提示的时候会显示 并没有什么用)

[self.locationManager requestAlwaysAuthorization];

2. 地图:<MapKit/MapKit.h>

1> iOS原生地图:

前面带MK的是系统自带的地图:

MKUserLocation:地图上的大头针 有title subtitle等属性

MKMapView:用来显示地图 与视图一样 初始化需要确定frame 定位的时候需要用到coreLocation框架

showsUserLocation 设置为YES 允许跟踪定位 (MKMapView的属性)

可自定义MKAnnotation

//     创建比例系数 显示在某个点上
MKCoordinateRegion region = MKCoordinateRegionMake(userLocation.coordinate, MKCoordinateSpanMake(0.1, 0.1)) ;
// 比例系数越小 放大效果越大
self.mapView.region = region; // 系统自带

2> 高德:

多以MA开头的:

[_mapView setZoomLevel:16.0 animated:YES];  设置缩放的比例

// 1. 验证key
[MAMapServices sharedServices].apiKey = @“申请的key”;
// 2. 初始化
mapView = [[MAMapView alloc] initWithFrame:CGRectMake(, , 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:跟随用户的位置和角度移动

系统的地图和 高德地图 的区别:http://www.mamicode.com/info-detail-573898.html

CoreLocation MKMapView的更多相关文章

  1. CoreLocation MKMapView 地图

    系统自带地图  框架: CoreLocation MapKit CLLocationManager --> 定位管理者  CLGeocoder --> 地理编码器 MKMapView -- ...

  2. MapKit/CoreLocation框架 总结

    MapKit/CoreLocation框架 /*英译 core:核心 track:踪迹 current:当前 statellite:卫星 hybird:混合  region:范围 annotation ...

  3. iOS - MKMapView 地图

    1.创建 MKMapView 地图 在 iOS6 或者 iOS7 中实现这个功能只需要添加地图控件.设置用户跟踪模式.在 mapView:didUpdateUserLocation: 代理方法中设置地 ...

  4. [iOS 利用MapKit和CoreLocation框架打造精简的定位和导航]

    运行效果:            一.利用<CoreLocation/CoreLocation.h>定位 创建变量 CLLocationManager *locationManager , ...

  5. iOS 利用CoreLocation和MapKit开发搜索附近的商场功能

    代码如下: ////  SearchNearbyShopViewController.m//  SearchNearbyShop////  Created by Linzhixiao on 16/2/ ...

  6. Corelocation及地图控件学习笔记

    Corelocation基本使用 在地图章节的学习中,首先要学的便是用户位置定位,因此我们首先要掌握Corelocation的使用.(在IOS8以前可以系统会直接请求授权,现在需要我们自己调用方式通知 ...

  7. iOS:地图:MapKit和CoreLocation

    地图:MapKit和CoreLocation 简介: 现在很多的社交软件都引入了地图和定位功能,要想实现这2大功能,那就不得不学习其中的2个框架:MaKit和CoreLocation CoreLoca ...

  8. CoreLocation+MapKit系统定位(含坐标以及详细地址)

    iOS8 之后出现一些新的配置 [self.manager requestWhenInUseAuthorization]; 并且在info.plist文件中增加 NSLocationWhenInUse ...

  9. (IOS)CoreLocation 和 MapKit 的应用

    CoreLocation是控制GPS硬件获取地理坐标信息的系统类库,而MapKit是系统地图的工具包,将两者结合使用可以实现不同的地图功能. 1.CoreLocation 在CoreLocation中 ...

随机推荐

  1. ckeditor_4.5.10_full上传图片功能

    1.找到image.js

  2. poj1691绘画板

    1 7 0 0 2 2 1 0 2 1 6 2 2 0 4 2 1 1 2 4 4 2 1 4 3 6 1 4 0 6 4 1 3 4 6 6 2 #include<stdio.h> #i ...

  3. SQL 存储过程 通过多个ID更新数据 分类: SQL Server 2014-12-08 16:08 299人阅读 评论(0) 收藏

    下面举个例子说明: 我想让一部分品牌的名称(即Brand_Name)后面加上1,Brand_ID是主键,sql语句很容易实现,但是存储过程如何写呢? 错误写法如下: //*************** ...

  4. eclipse GWT开发环境的离线布置方法

    安装方法http://blog.csdn.net/u011029071/article/details/10143841 用eclipse自动更新安装失败N次,还是得手动来 以Google Plugi ...

  5. 语音控制的tab选项卡

    前端开发whqet,csdn,王海庆,whqet,前端开发专家 ladies and 乡亲们,程序猿同志们,周末仍然坚守工作岗位,或者学习不辍的童鞋们,福音来了. 语音识别高不高端.难不难? 今天给大 ...

  6. struts 2学习笔记—初学struts 2

    首先我学习了struts 1.x与struts 2的区别: 1.struts 1.x的控制器类必须从Action类继承. 2.struts 2的控制器类可以是一个普通的类,也可以是ActionSupp ...

  7. Android获得线性渐变某点的颜色

    安卓官方确实提供了好多非常强大的工具给我们了,例如我们最近经常在shape中加入gradient(渐变),像我的项目中用的是线性渐变, <?xml version="1.0" ...

  8. FastDFS配置说明(中英文)

    FastDFS配置说明 1)tracker.conf # is this config file disabled # false for enabled # true for disabled di ...

  9. python - 操作RabbitMQ

    python - 操作RabbitMQ     介绍 RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议.MQ全称为Mess ...

  10. 19、XHTML

    XHTML 可扩展超文本标签语言(EXtensible HyperText Markup Language). 是一种 W3C 标准. 更严格,更纯净的HTML代码. 目标是取代HTML代码. XHT ...