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

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. MongoDB Java 连接配置

    [前言] 由于处于线程安全等考虑,MongoDBJava从3.0开始已经打算废弃DB开头的类的使用,所以整体调用上有了较大的区别,特以此文志之 [正文] 环境配置 在Java程序中如果要使用Mongo ...

  2. spring项目中监听器作用-ContextLoaderListener(转)

    1 spring框架的启动入口 ContextLoaderListener 2 作用:在启动Web 容器时,自动装配Spring applicationContext.xml 的配置信息. 因为它实现 ...

  3. Android教程:ImageView 设置图片

    Android doc中是这样描述的: public void setImageResource (int resId) 这是其中的一个方法,参数resld是这样: ImageView.setImag ...

  4. c++截取屏幕图片并保存(函数代码实现)

    <strong> //获取桌面窗体的CDC CDC *pdeskdc = GetDesktopWindow()->GetDC(); CRect re; //获取窗体的大小 GetDe ...

  5. [JavaScript] Array.prototype.reduce in JavaScript by example

    Let's take a closer look at using Javascript's built in Array reduce function. Reduce is deceptively ...

  6. android 52 粘滞广播

    粘滞广播:广播发送出去以后,广播接收者还没有创建,当广播接收者注册的时候就可以接收,如果不是粘滞广播则如果没有广播接收者就以后不能再接收了. mainActivity: package com.sxt ...

  7. javascript 可控速度的上下拉菜单

    样式部分 <style type="text/css"> *{ margin:0; padding:0; border:none; background:none;} ...

  8. Eclipse中文语言包下载

    Kepler .Juno . Indigo语言包: http://www.eclipse.org/babel/downloads.php 其他低版本Eclipse语言包下载: http://archi ...

  9. Java基础知识强化之集合框架笔记22:List集合的三个子类的特点(面试题)

    1. List:(面试题List的子类特点)(1)ArrayList: 底层数据结构是数组,查询快,增删慢. 线程不安全,效率高.(2)Vector: 底层数据结构是数组,查询快,增删慢. 线程安全, ...

  10. EXCEL插件

    http://www.cnblogs.com/brooks-dotnet/category/233027.html http://www.360doc.com/content/15/0713/00/1 ...