利用三方SDK实现导航(百度) >当点击开始导航时获取用户输入的起点和终点 >利用GEO对象进行地理编码获取到地标对象(CLPlacemark ) >再利用获取到的地标对象(CLPlacemark)创建MKPlacemark >利用MKPlacemark创建起点的item >终点和起点逻辑一样 1.发送请求到苹果的服务器获取导航路线信息 2.根据服务器返回的路线信息自己绘制导航路线 代码1 1 // 2 // ViewController.m *startPlacemark = [[MKPlacemark alloc] initWithPlacemark:startCLPlacemark]; 84 MKMapItem *startItem = [[MKPlacemark alloc] initWithPlacemark:endCLPlacemark]; 88 MKMapItem *endItem = [[MKMapItem alloc = [[MKPlacemark alloc] initWithPlacemark:endCLPlacemark]; 95 MKMapItem *endItem = [[MKMapItem alloc
一、线路导航 1、从几个类的关系说起 (1)MKPlacemark 一个地点信息类,如下: @interface MKPlacemark : CLPlacemark <MKAnnotation> //初始化方法 地点节点类,包含此节点的许多地点信息,如下: @interface MKMapItem : NSObject //当前节点的地点信息对象 @property (nonatomic, readonly) MKPlacemark 将当前位置创建为节点 + (MKMapItem *)mapItemForCurrentLocation; //由一个位置信息创建节点 - (instancetype)initWithPlacemark:(MKPlacemark CLLocationCoordinate2D tocoor = CLLocationCoordinate2DMake(33.33, 113.33); //创建出发点和目的点信息 MKPlacemark addressDictionary:nil]; MKPlacemark *toPlace = [[MKPlacemark alloc]initWithCoordinate:tocoor addressDictionary
一、打开系统地图进行导航(modal出新的界面,跳到系统的地图界面) 步骤: 1、创建地理编码对象,调用正地理编码方法,获取 CLPlacemark 地标对象 2、构造方法用上面参数创建一个 MKPlacemark 创建MKPlacemark对象 MKPlacemark *mkpm = [[MKPlacemark alloc] initWithPlacemark:pm]; //6. 以后无法在模拟器运行 步骤:(就是各种转换,步骤多的看着就恶心,可以直接看下面代码) 1、创建地理编码对象,调用正地理编码方法,获取 CLPlacemark 地标对象 2、构造方法用上面参数创建一个 MKPlacemark 创建MKPlacemark对象 MKPlacemark *mkpm = [[MKPlacemark alloc] initWithPlacemark:pm]; //6.1
animated; //将要更改 -(void)mapView: (MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; //已经更改 MKPlacemark 、MKUserLocation和MKReverseGeocoder 在地图上做标记是通过MKPlacemark类来完成的。 MKPlacemark保存了位置(经纬度)和地址(字典类)之间的映射。 MKPlacemark保存了位置(经纬度)和地址之间的映射。那么,有没有工具在这两者之间做转换呢?这就是MKRecerseGeocoder.给定一个位置信息,这个类可以返回相应的地址信息。 void)cancel; //取消转换 回调的方法有: -(void)reverseGeocoder:(MKReverseGeocoder *) geocoded didFindPlacemark:(MKPlacemark
mapItemForCurrentLocation]; CLLocationCoordinate2D gc02Coor = [TQLocationConverter transformFromBaiduToGCJ:toCoor]; MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:gc02Coor addressDictionary:nil]; MKMapItem *toLocation
mapItemForCurrentLocation]; //终点位置 MKMapItem *toLocation = [[MKMapItem alloc]initWithPlacemark:[[MKPlacemark
mapItemForCurrentLocation]; //终点位置 MKMapItem *toLocation = [[MKMapItem alloc]initWithPlacemark:[[MKPlacemark
let currentLocation = MKMapItem.forCurrentLocation() let toLocation = MKMapItem(placemark:MKPlacemark
escaping ([MKRouteStep]) -> Void) { var steps: [MKRouteStep] = [] let placeMark = MKPlacemark route.steps) } completion(steps) } } } } 定义 MKPlacemark
MKMapItem mapItemForCurrentLocation]; MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark
Waypoint: Identifiable {} extension Waypoint { var mapItem: MKMapItem { return MKMapItem(placemark: MKPlacemark