中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

IOS 8 使用系統(tǒng)自帶導航

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
//
//  ViewController.m
//  APP自帶導航
//
//  Created by wup on 15/5/23.
//  Copyright (c) 2015年 apple. All rights reserved.
//
#import "ViewController.h"
#import <MapKit/MapKit.h>
@interface ViewController ()
@property (nonatomic,strong)  CLGeocoder *geo;
@end
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//    CLLocationManager *clmgr = [[CLLocationManager alloc] init];
//    [clmgr requestAlwaysAuthorization];
     
//    MKMapView *mv = [[MKMapView alloc] initWithFrame:self.view.bounds];
//    [self.view addSubview:mv];
    [self.geo  geocodeAddressString:@"麗江" completionHandler:^(NSArray *placemarks, NSError *error) {
       
         
       
         //獲取到起點的MKplaceMark
         
        MKPlacemark *startPlace = [[MKPlacemark alloc] initWithPlacemark:[placemarks firstObject]];
         
        //等待獲取到起點的placemarks之后在獲取終點的placemarks,block回調延遲問題
        [self.geo  geocodeAddressString:@"北京" completionHandler:^(NSArray *placemarks, NSError *error) {
             
            /**
              獲取到終點的MKplaceMark,MKPlaceMark 是ClPlaceMark的子類。
             */
            MKPlacemark *endPlace = [[MKPlacemark alloc] initWithPlacemark:[placemarks firstObject]];
             
            /**
             將MKPlaceMark轉換成MKMapItem,這樣可以放入到item這個數(shù)組中
  
             */
            MKMapItem *startItem = [[MKMapItem alloc ] initWithPlacemark:startPlace];
            MKMapItem *endItem = [[MKMapItem alloc ] initWithPlacemark:endPlace];
             
            NSArray *item = @[startItem ,endItem];
             
            //建立字典存儲導航的相關參數(shù)
            NSMutableDictionary *md = [NSMutableDictionary dictionary];
            md[MKLaunchOptionsDirectionsModeKey] = MKLaunchOptionsDirectionsModeDriving;
            md[MKLaunchOptionsMapTypeKey] = [NSNumber numberWithInteger:MKMapTypeHybrid];
             
             
             
             
            /**
             *調用app自帶導航,需要傳入一個數(shù)組和一個字典,數(shù)組中放入MKMapItem,
             字典中放入對應鍵值
              
             MKLaunchOptionsDirectionsModeKey   開啟導航模式
             MKLaunchOptionsMapTypeKey  地圖模式
                                                 MKMapTypeStandard = 0,
                                                 MKMapTypeSatellite,
                                                 MKMapTypeHybrid
              
             // 導航模式
             MKLaunchOptionsDirectionsModeDriving 開車;
             MKLaunchOptionsDirectionsModeWalking 步行;
             */
#warning 其實所有的代碼都是為了下面一句話,打開系統(tǒng)自帶的高德地圖然后執(zhí)行某些動作,launchOptions里面的參數(shù)指定做哪些動作
            [MKMapItem openMapsWithItems:item launchOptions:md];
        }];
    }];
  
}
#pragma mark - 超級懶加載
-(CLGeocoder *)geo
{
    if (!_geo)
    {
        _geo = [[CLGeocoder alloc] init];
         
    }
    return  _geo;
}
@end

標簽: 代碼

版權申明:本站文章部分自網絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:C++編寫的俄羅斯方塊代碼

下一篇:C++編寫的21點小游戲代碼