關於高德地圖在iOS中呼叫騎行導航
SDK中實時導航時可以進行不同的路線規劃,這塊又跳到各自的路徑規劃頁面,或者串聯不起來。高德給的demo中也沒有騎行導航的相關示例,網上也查不到相關有用的資訊,所以只能自己深入檢視SDK,發現如果想要實現在移動端的騎行導航,步驟如下:
1、獲取起始點和終點的經緯度座標
- (void)initProperties { self.startPoint = [AMapNaviPoint locationWithLatitude:39.99 longitude:116.47]; self.endPoint = [AMapNaviPoint locationWithLatitude:39.90 longitude:116.32]; }
2、引入騎行導航介面AMapNaviRideView
- (void)initDriveView { if (self.driveView == nil) { self.driveView = [[AMapNaviRideView alloc] initWithFrame:self.view.bounds]; self.driveView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; [self.driveView setDelegate:self];
[self.driveView setTrackingMode:AMapNaviViewTrackingModeMapNorth]; [self.view addSubview:self.driveView]; } }
3、引入騎行管理類
- (void)initRideManager { if (!self.rideManager) { self.rideManager = [[AMapNaviRideManager alloc] init]; [self.rideManager setDelegate:self];
[self.rideManager addDataRepresentative:self.driveView]; } }
4、進行路徑規劃
[self.rideManager calculateRideRouteWithStartPoint:self.startPoint endPoint:self.endPoint];
5、路徑規劃成功後的delegete回撥處理
/** * @brief 騎行路徑規劃成功後的回撥函式 * @param rideManager 騎行導航管理類 */ - (void)rideManagerOnCalculateRouteSuccess:(AMapNaviRideManager *)rideManager{ //算路成功後開始GPS導航 [rideManager startGPSNavi]; }
希望能夠幫助到有需要的同學們,有問題可以評論,看到會回覆。