当前位置:首页 > 操作系统 > Ios

IOS百度地图语音导航

            VoiceNavigationViewController.m


            
                * 客户端需安装百度导航地图


            
            #import
            "
            VoiceNavigationViewController.h
            "
            #import
            "
            BMapKit.h
            "
            #import
            "
            BMKNavigation.h
            "
            @interface VoiceNavigationViewController ()<BMKMapViewDelegate>
{
    BMKMapView* _mapView;
}

@end@implementation VoiceNavigationViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization    }
    return self;
}

-(void)viewWillAppear:(BOOL)animated {
    //    [_mapView viewWillAppear];
    _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放}

-(void)viewWillDisappear:(BOOL)animated {
    [_mapView viewWillDisappear];
    _mapView.delegate = nil; // 不用时,置nil}

- (void)nativeNavi
{
    //初始化调启导航时的参数管理类
    NaviPara* para = [[NaviPara alloc]init];
    //指定导航类型
    para.naviType = NAVI_TYPE_NATIVE; // 移动客户端
    
    //初始化终点节点
    BMKPlanNode* end = [[BMKPlanNode alloc]init];
    //指定终点经纬度    CLLocationCoordinate2D coor2;
    coor2.latitude = 129.59;
    coor2.longitude = 106.54;
    end.pt = coor2;
    //指定终点名称
    end.name = @"新牌坊西";
    //指定终点
    para.endPoint = end;
    
    //指定返回自定义scheme
    para.appScheme = @"baidumapsdk://mapsdk.baidu.com";
    
    //调启百度地图客户端导航    [BMKNavigation openBaiduMapNavigation:para];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.    
    [self nativeNavi];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.}

@end

原文:http://www.cnblogs.com/joesen/p/3591732.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!