一、Core  Location

1、基本对象

@propertys: coordinate, altitude, horizontal/verticalAccuracy, timestamp, speed, course

@property (readonly) CLLocationCoordinate2D coordinate;

typedef {

CLLocationDegrees latitude; //   double型 纬度

CLLocationDegrees longitude; //  double 型 经度

} CLLocationCoordinate2D;

@property (readonly) CLLocationDistance altitude;  //高度 (单位:米)

2、精度

kCLLocationAccuracyBestForNavigation  //精度最好,但同时最耗电,以下类推

kCLLocationAccuracyBest

kCLLocationAccuracyNearestTenMeters

kCLLocationAccuracyHundredMeters

kCLLocationAccuracyKilometer

kCLLocationAccuracyThreeKilometers

3、如何获得Core Location?[通过CLLocationManager]

通常的步骤是:(1 通过硬件获得支持  (2 创建一个CLLocationManager实例并设置委托 (3 配置如何更新、精度 (4 开启这个Manager运行

4、在最开始创建Location Manager的时候,需要检查下面这些项:

+ (CLAuthorizationStatus)authorizationStatus; //* 检查应用的授权状态 *应用在第一次启动时,会自动请求授权,应用应当明确被授权使用位置服务,并且位置服务当前出于运行状态,应用才能使用位置服务。

+ (BOOL)locationServicesEnabled; // * 判断用户是否启动位置服务 * 在启动位置更新操作之前,用户应当检查该方法的返回值来查看设备的位置服务是否启动。如果位置服务没有启动,而用户又启动了位置更新操作,那么Core Location 框架将会弹出一个让用户确认是否启动位置服务的对话框。

+ (BOOL)significantLocationChangeMonitoringAvailable; //* 表明设备能否报告基于significant location changges的更新 *(significant location change监控,只是基于设备所链接的蜂窝塔的位置改变诊断,在精度要求不高的情况下,可以节省很多电量。)

+(BOOL)isMonitoringAvailableForClass:(Class)regionClass;//  对某些设备 beacon的监听

+ (BOOL)isRangingAvailable;//* 返回蓝牙信号范围服务是否可用 *。这是iOS 7新增的方法

5、委托

(1 属性

@property CLLocationAccuracy desiredAccuracy; // 精度

@property CLLocationDistance distanceFilter; // 距离过滤器:超过多远的距离才开始重新定位

(2 定位

- (void)startUpdatingLocation;   //开启定位
 - (void)stopUpdatingLocation;   //关闭定位

- (void)startMonitoringSignificantLocationChanges;    //可以在后台或者前台都能监视到用户位置的移动,即使程序没有启动

- (void)stopMonitoringSignificantLocationChanges;  //

(3 当你的程序没有运行或者后台被启动的时候,这个方法会被发送

application:didFinishLaunchingWithOptions:  UIApplicationLaunchOptionsLocationKey

(4 圆形范围[基于对区域的监控]

- (void)startMonitoringForRegion:(CLRegion *)region; // CLCircularRegion/CLBeaconRegion

- (void)stopMonitoringForRegion:(CLRegion *)region;

//进入范围的时候,会发送广播通知你[这是iOS7 新增的]

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;

- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region

withError:(NSError *)error;

接下就可以讲讲MapKit:

二、MKMapView

1、annotations :通过点击会弹出一个 MKAnnotationView

@property (readonly) NSArray *annotations;

@protocol  MKAnnotation <NSObject>

@property  (readonly) CLLocationCoordinate2D coordinate;//

@optional

@property  (readonly) NSString *title;  //标题

@property  (readonly) NSString *subtitle;//副标题

@end

typedef {

CLLocationDegrees latitude;

CLLocationDegrees longitude;//经纬度

} CLLocationCoordinate2D;

2、MKAnnotationView

@property id <MKAnnotation> annotation;

@property UIImage *image;  //可以修改如上图的大头针的图片
@property UIView *leftCalloutAccessoryView;  //弹出View的修改
@property UIView *rightCalloutAccessoryView;

@property BOOL enabled;

@property CGPoint centerOffset;

@property BOOL draggable;

(1 [非常像UITableView]创建视图(不创建会自动创建)

- (MKAnnotationView *)mapView:(MKMapView *)sender viewForAnnotation:(id <MKAnnotation>)annotation

{

MKAnnotationView *aView = [sender dequeueReusableAnnotationViewWithIdentifier:IDENT];

if (!aView) {

aView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation

reuseIdentifier:IDENT];

aView.annotation = annotation;

return aView;

}

(2  View里面的图标被轻点事件

- (void)mapView:(MKMapView *)sender   annotationView:(MKAnnotationView *)aView

calloutAccessoryControlTapped:(UIControl *)control;

(3 大头针被轻点事件

- (void)mapView:(MKMapView *)sender didSelectAnnotationView:(MKAnnotationView *)aView

{

if ([aView.leftCalloutAccessoryView isKindOfClass:[UIImageView class]])

{

UIImageView *imageView = (UIImageView *)aView.leftCalloutAccessoryView;

imageView.image = ...;

}

}

(4 调用摄像头操作

+ (MKMapCamera *)cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)coord

fromEyeCoordinate:(CLLocationCoordinate2D)cameraPosition

eyeAltitude:(CLLocationDistance)eyeAltitude;

(5  设置动画效果:比如地理位置的转移,先从上的转移,然后再从上到下

   - (void)mapView:(MKMapView *)mapView didChangeRegionAnimated:(BOOL)animated;

3、MKLocalSearch 搜索

(1 搜索

MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];

request.naturalLanguageQuery = @“Ike’s”;

request.region = ...;

MKLocalSearch *search = [[MKLocalSearch alloc] initWithRequest:request];

[search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {  // 得到一个MKMapItem 数组,里面还包含MKPlacemark  }];

(2 在地图APP中打开

- (BOOL)openInMapsWithLaunchOptions:(NSDictionary *)options;

4、MKDirections 路线

三、Embed Segue 
      Container View

OC开发_Storyboard——MapKit的更多相关文章

  1. OC开发_Storyboard——iPad开发

    iPad开发(Universal Applications) 一.iPad 1.判断是否在iPad上 BOOL iPad = ([[UIDevice currentDevice] userInterf ...

  2. OC开发_Storyboard——AutoLayout

    一.autolayout 自动布局: 1. 设置所有视图框架的三种方法,可以通过代码创建也可以storyboard设置 = 规则 (1 蓝线+约束:(位置) 使用蓝线,根据蓝线拖动控件,只是告诉Xco ...

  3. OC开发_Storyboard——多线程、UIScrollView

    一.多线程 1.主队列:处理多点触控和所有UI操作(不能阻塞.主要同步更新UI) dispatch_queue_t mainQueue = dispatchg_get_main_queue(); // ...

  4. OC开发_Storyboard——UITableView

    一.tableView 1.datasource数据源 (1 构造每一个tableVIewCell的方法:cellForRowAtIndexPath,这里的 dequeueReusableCellWi ...

  5. OC开发_Storyboard——Core Data

    一 .NSManagedObjectContext 1.我们要想操作Core Data,首先需要一个NSManagedObjectContext2.那我们如何获得Context呢:创建一个UIMana ...

  6. OC开发_Storyboard——UIApplication和网络活动指示器

    一.UIApplication 只有一个实例: UIApplication *myApplication = [UIApplication sharedApplication]; 属性如果设置为YES ...

  7. OC开发_Storyboard——绘制和视图

    1.绘制 不要调用drawRect.调用setNeedsDisplay相当于告知系统视图需要重绘, 它会去调用drawRect,更新屏外缓冲器 2.UIBezierPath绘制图形,   设置图像op ...

  8. OC开发_Storyboard——block和动画

     一.协议 @optional :可选的 @requied :必须实现的  二.block 代码块 1. 以一个^开头,然后是参数,然后是一个大括号,包含我们的代码块 [aDictionary enu ...

  9. OC开发_Storyboard——NaviationController简单例子

    一个简单的Navigation的例子,demo里面用到了上一个demo的MVC,可以参考下:http://www.cnblogs.com/daomul/p/4426063.html 建立一个Nav其实 ...

随机推荐

  1. SpringBoot整合cxf发布webService

    1. 看看项目结构图 2. cxf的pom依赖 1 <dependency>2 <groupId>org.apache.cxf</groupId>3 <art ...

  2. Unity接第三方SDK时遇到的坑

    1.大部分SDK的方法需要在线程中执行,一般会放在主线程里执行,安卓中主线程一般用于UI渲染. this.runOnUiThread(new Runnable() { @Override public ...

  3. linux 中搜索命令的对比

    1.find find是最常用和最强大的查找命令.它能做到实时查找,精确查找,但速度慢. find的使用格式如下: #find [指定目录] [指定条件] [指定动作] 指定目录:是指所要搜索的目录和 ...

  4. Ulua_toLua_基本案例(六)_LuaCoroutine2

    Ulua_toLua_基本案例(六)_LuaCoroutine2 using UnityEngine; using System.Collections; using LuaInterface; pu ...

  5. 01-虚拟软件vmware安装

    什么是虚拟软件: 虚拟原件是一个可以使你在一台机器上同时运行二个或更多Windows.LINUX等系统.它可以模拟一个标准PC环境.这个环境和真实的计算机一样,都有芯片组.CPU.内存.显卡.声卡.网 ...

  6. css媒体查询移动优先和pc优先

    移动优先,默认你是用手机浏览该网页的,当你用pc浏览时,就会以min-width进行递增式媒体查询 <!DOCTYPE html> <html lang="en" ...

  7. ios开发之--复制到剪切板

    仅做记录: UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = @"你好&quo ...

  8. 【安全开发】PHP安全编码规范

    申明:本文非笔者原创,原文转载自:https://github.com/SecurityPaper/SecurityPaper-web/blob/master/_posts/2.SDL%E8%A7%8 ...

  9. java-RAC Oracle 连接字符串

    昨天在访问oracle数据库取数据时遇到一个问题: 上网搜索一下发现是我访问的数据库做了RAC,原有的数据库连接字符串不适用,原来的连接字符串如下所示: 使用下面的字符串解决了该问题: String ...

  10. HTML 样式

    style 属性用于改变 HTML 元素的样式,常见的样式如下: 定义字体颜色:style="color:red"定义字体大小:style="font-size:20px ...