#import "AMapNaviViewManager.h"

#pragma mark - 驾车导航ViewManager

@implementation AMapNaviViewManager {
    AMapNaviView *_driveView;
}

RCT_EXPORT_MODULE(ADriveNaviView)

- (UIView *)view
{
    AMapNaviView *driveView =  [AMapNaviView new];
    driveView.delegate = self;
    [driveView setShowMode:AMapNaviDriveViewShowModeOverview];
    [[AMapNaviDriveManager sharedInstance] setDelegate:self];
    //设置后才会显示导航线路
    [[AMapNaviDriveManager sharedInstance] addDataRepresentative: driveView];
    //将当前VC添加为导航数据的Representative，使其可以接收到导航诱导数据
    //设置后才有数据回调
    [[AMapNaviDriveManager sharedInstance] addDataRepresentative:self];
    [[AMapNaviDriveManager sharedInstance] setAllowsBackgroundLocationUpdates:YES];
    [[AMapNaviDriveManager sharedInstance] setPausesLocationUpdatesAutomatically:NO];
    _driveView = driveView;
    
    return driveView;
}

RCT_EXPORT_VIEW_PROPERTY(onInitNaviFailure, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onInitNaviSuccess, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onStartNavi, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLocationChange, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGetNavigationText, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onEndEmulatorNavi, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteFailure, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onArrivedWayPoint, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGpsOpenStatus, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteSuccess, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPlayRing, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGpsSignaChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviSettingChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviCancel, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviComplete, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviViewLoaded, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviBackClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onScanViewButtonClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapViewModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapViewTrackingModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLockMap, RCTBubblingEventBlock)

RCT_CUSTOM_VIEW_PROPERTY(layoutVisible, BOOL, AMapNaviView) {
    view.showUIElements = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(autoChangeZoom, BOOL, AMapNaviView) {
    view.autoZoomMapLevel = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(autoDayNightMode, BOOL, AMapNaviView) {
    if([RCTConvert BOOL:json]) {
        view.mapViewModeType = AMapNaviViewMapModeTypeDayNightAuto;
    } else {
         view.mapViewModeType = AMapNaviViewMapModeTypeDay;
    }
}
RCT_CUSTOM_VIEW_PROPERTY(cameraBubbleVisible, BOOL, AMapNaviView) {
    view.showCamera = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(compassVisible, BOOL, AMapNaviView) {
    view.showCompass = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(turnArrowVisible, BOOL, AMapNaviView) {
    view.showTurnArrow = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(moreButtonVisible, BOOL, AMapNaviView) {
    view.showMoreButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(browseButtonVisible, BOOL, AMapNaviView) {
    view.showBrowseRouteButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(tilt, CGFloat, AMapNaviView) {
    view.cameraDegree = [RCTConvert CGFloat:json];
}
RCT_CUSTOM_VIEW_PROPERTY(trafficBarVisible, BOOL, AMapNaviView) {
    view.showTrafficBar = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(trafficButtonVisible, BOOL, AMapNaviView) {
    view.showTrafficButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(trafficLineVisible, BOOL, AMapNaviView) {
    view.mapShowTraffic = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(startMarkerIcon, UIImage, AMapNaviView) {
    view.startPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(endMarkerIcon, UIImage, AMapNaviView) {
    view.endPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(carMarkerIcon, UIImage, AMapNaviView) {
    view.carImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(fourCornersIcon, UIImage, AMapNaviView) {
    view.carCompassImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(wayMarkerIcon, UIImage, AMapNaviView) {
    view.wayPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(autoLockCar, BOOL, AMapNaviDriveView)
{
    [view setAutoSwitchShowModeToCarPositionLocked:[RCTConvert BOOL:json]];
}
RCT_CUSTOM_VIEW_PROPERTY(showMode, NSInteger, AMapNaviView) {
    view.trackingMode = (AMapNaviViewTrackingMode)[RCTConvert NSInteger:json];
}
RCT_CUSTOM_VIEW_PROPERTY(trackingMode, NSInteger, AMapNaviView) {
    view.showMode = (AMapNaviDriveViewShowMode)[RCTConvert NSInteger:json];
}

RCT_CUSTOM_VIEW_PROPERTY(navi, NaviParams, AMapNaviView) {
    NaviParams* params = [RCTConvert NaviParams: json];
    if(params == nil) {
        return;
    }
    if(params.type != 1) {
        return;
    }
    if(params.to == nil || params.to.count == 0) {
        return;
    }
    if([params.to[0] isKindOfClass:[AMapNaviPoint class]]) {
        if(params.from != nil) {
            [[AMapNaviDriveManager sharedInstance] calculateDriveRouteWithStartPoints:params.from
                                                                            endPoints:params.to
                                                                            wayPoints:params.wayPoints
                                                                      drivingStrategy:params.strategy];
        } else {
            [[AMapNaviDriveManager sharedInstance] calculateDriveRouteWithEndPoints:params.to
                                                                          wayPoints:params.wayPoints
                                                                    drivingStrategy:params.strategy];
        }
        
    } else if([params.to[0] isKindOfClass:[NSString class]]) {
        [[AMapNaviDriveManager sharedInstance] calculateDriveRouteWithStartPointPOIId:params.from[0]
                                                                        endPointPOIId:params.to[0]
                                                                       wayPointsPOIId:params.wayPoints
                                                                      drivingStrategy:params.strategy];
    } else if([params.to[0] isKindOfClass:[AMapNaviPOIInfo class]]) {
        [[AMapNaviDriveManager sharedInstance] calculateDriveRouteWithStartPOIInfo:params.from[0]
                                                                        endPOIInfo:params.to[0]
                                                                       wayPOIInfos:params.wayPoints
                                                                   drivingStrategy:params.strategy];
    }
}

RCT_EXPORT_METHOD(startNavi:(nonnull NSNumber *)reactTag type:(NSInteger)type speed:(NSInteger)speed) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        switch (type) {
            case 1:
                [[AMapNaviDriveManager sharedInstance] startGPSNavi];
                break;
            case 2:
                [[AMapNaviDriveManager sharedInstance] setEmulatorNaviSpeed:(int)speed];
                [[AMapNaviDriveManager sharedInstance] startEmulatorNavi];
                break;
            default:
                break;
        }
    }];
}

RCT_EXPORT_METHOD(stopNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviDriveManager sharedInstance] stopNavi];
    }];
}

RCT_EXPORT_METHOD(pauseNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviDriveManager sharedInstance] pauseNavi];
    }];
}

RCT_EXPORT_METHOD(resumeNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviDriveManager sharedInstance] resumeNavi];
    }];
}

RCT_EXPORT_METHOD(startGPS:(nonnull NSNumber *)reactTag) {
}


RCT_EXPORT_METHOD(stopGPS:(nonnull NSNumber *)reactTag) {
}


#pragma mark - AMapNaviDriveDataRepresentable

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateNaviMode:(AMapNaviMode)naviMode {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateNaviRouteID:(NSInteger)naviRouteID {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateNaviRoute:(nullable AMapNaviRoute *)naviRoute {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateNaviInfo:(nullable AMapNaviInfo *)naviInfo{
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateNaviLocation:(nullable AMapNaviLocation *)naviLocation
{
    if(_driveView.onLocationChange) {
        _driveView.onLocationChange(@{
            @"accuracy":@(naviLocation.accuracy),
            @"altitude":@(naviLocation.altitude),
            @"bearing":@(naviLocation.heading),
            @"coord" : @{@"latitude":@(naviLocation.coordinate.latitude), @"longitude":@(naviLocation.coordinate.longitude)},
            @"curLinkIndex":@(naviLocation.currentLinkIndex),
            @"curStepIndex":@(naviLocation.currentSegmentIndex),
            @"speed":@(naviLocation.speed),
            @"time":[NSNumber numberWithDouble:[naviLocation.timestamp timeIntervalSinceReferenceDate]] });
    };
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager showCrossImage:(UIImage *)crossImage {
}

- (void)driveManagerHideCrossImage:(AMapNaviDriveManager *)driveManager{
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager showLaneBackInfo:(NSString *)laneBackInfo laneSelectInfo:(NSString *)laneSelectInfo {
}

- (void)driveManagerHideLaneInfo:(AMapNaviDriveManager *)driveManager{
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateTrafficStatus:(nullable NSArray<AMapNaviTrafficStatus *> *)trafficStatus {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateCameraInfos:(nullable NSArray<AMapNaviCameraInfo *> *)cameraInfos {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager updateServiceAreaInfos:(nullable NSArray<AMapNaviServiceAreaInfo *> *)serviceAreaInfos
{
    NSLog(@"updateServiceAreaInfos");
}

#pragma mark - AMapNaviDriveManager Delegate

- (void)driveManager:(AMapNaviDriveManager *)driveManager error:(NSError *)error {
    if(_driveView.onInitNaviFailure) {
        _driveView.onInitNaviFailure(@{@"errorCode": [NSNumber numberWithInteger:error.code] });
    }
}

- (void)driveManagerOnCalculateRouteSuccess:(AMapNaviDriveManager *)driveManager {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager onCalculateRouteSuccessWithType:(AMapNaviRoutePlanType)type {
    if(_driveView.onCalculateRouteSuccess) {
        _driveView.onCalculateRouteSuccess(@{@"errorCode": @0, @"errorDetail": @"success", @"errorDescription": @"", @"routeId": driveManager.naviRouteIDs });
    }
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager onCalculateRouteFailure:(NSError *)error {
    if(_driveView.onCalculateRouteFailure) {
        _driveView.onCalculateRouteFailure(@{@"errorCode":@(error.code),@"errorDetail":error.domain, @"errorDescription": error.localizedDescription});
    }
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager didStartNavi:(AMapNaviMode)naviMode {
    if(_driveView.onStartNavi) {
        _driveView.onStartNavi(nil);
    }
}

- (void)driveManagerNeedRecalculateRouteForYaw:(AMapNaviDriveManager *)driveManager {
}

- (void)driveManagerNeedRecalculateRouteForTrafficJam:(AMapNaviDriveManager *)driveManager {
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager onArrivedWayPoint:(int)wayPointIndex {
    if(_driveView.onArrivedWayPoint) {
        _driveView.onArrivedWayPoint(@{@"wayId": [NSNumber numberWithInt:wayPointIndex]});
    }
}

- (BOOL)driveManagerIsNaviSoundPlaying:(AMapNaviDriveManager *)driveManager {
    return [[SpeechSynthesizer sharedSpeechSynthesizer] isSpeaking];
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager playNaviSoundString:(NSString *)soundString soundStringType:(AMapNaviSoundType)soundStringType {
    [[SpeechSynthesizer sharedSpeechSynthesizer] speakString:soundString];
    if(_driveView.onGetNavigationText) {
        _driveView.onGetNavigationText(@{@"text": soundString});
    }
}

- (void)driveManagerDidEndEmulatorNavi:(AMapNaviDriveManager *)driveManager {
    if(_driveView.onEndEmulatorNavi) {
        _driveView.onEndEmulatorNavi(nil);
    }
}

- (void)driveManagerOnArrivedDestination:(AMapNaviDriveManager *)driveManager {
    if(_driveView.onNaviComplete) {
        _driveView.onNaviComplete(nil);
    }
}

- (void)driveManager:(AMapNaviRideManager *)driveManager updateGPSSignalStrength:(AMapNaviGPSSignalStrength)gpsSignalStrength {
    if(_driveView.onGpsSignaChanged) {
        _driveView.onGpsSignaChanged(@{@"status": @(gpsSignalStrength)});
    }
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager onNaviPlayRing:(AMapNaviRingType)ringType {
    if(_driveView.onPlayRing) {
        _driveView.onPlayRing(nil);
    }
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager postRouteNotification:(AMapNaviRouteNotifyData *)notifyData {
}

#pragma mark - AMapNaviDriveViewDelegate

- (void)driveViewCloseButtonClicked:(AMapNaviDriveView *)driveView {
    if (_driveView.onNaviBackClick) {
        _driveView.onNaviBackClick(nil);
    }
}

- (void)driveViewMoreButtonClicked:(AMapNaviDriveView *)driveView {
}

- (void)driveViewTrunIndicatorViewTapped:(AMapNaviDriveView *)driveView {
}

- (void)driveView:(AMapNaviDriveView *)driveView didChangeShowMode:(AMapNaviDriveViewShowMode)showMode {
    if(_driveView.onNaviMapModeChanged) {
        _driveView.onNaviMapModeChanged(@{@"mode": @(showMode)});
    }
    if(showMode == AMapNaviDriveViewShowModeCarPositionLocked && _driveView.onLockMap) {
        _driveView.onLockMap(nil);
    }
}

-(void)driveView:(AMapNaviDriveView *)driveView didChangeTrackingMode:(AMapNaviViewTrackingMode)trackMode {
    if(_driveView.onNaviMapViewTrackingModeChanged) {
        _driveView.onNaviMapViewTrackingModeChanged(@{@"mode": @(trackMode)});
    }
}

- (void)driveView:(AMapNaviDriveView *)driveView didChangeDayNightType:(BOOL)showStandardNightType {
    if(_driveView.onNaviMapViewModeChanged) {
        _driveView.onNaviMapViewModeChanged(@{@"mode": @(driveView.mapViewModeType)});
    }
}

@end

#pragma mark - 骑行导航ViewManger

@implementation AMapRideNaviViewManager {
    AMapRideNaviView *_rideView;
}

RCT_EXPORT_MODULE(ARideNaviView)

-(UIView*)view {
    _rideView = [AMapRideNaviView new];
    [_rideView setDelegate:self];
    
    [[AMapNaviRideManager sharedInstance] setDelegate:self];
    [[AMapNaviRideManager sharedInstance] addDataRepresentative:self];
    //将driveView添加为导航数据的Representative，使其可以接收到导航诱导数据
    [[AMapNaviRideManager sharedInstance] addDataRepresentative:_rideView];
    [[AMapNaviRideManager sharedInstance] setAllowsBackgroundLocationUpdates:YES];
    [[AMapNaviRideManager sharedInstance] setPausesLocationUpdatesAutomatically:NO];
    
    return _rideView;
}

RCT_EXPORT_VIEW_PROPERTY(onInitNaviFailure, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onInitNaviSuccess, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onStartNavi, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLocationChange, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGetNavigationText, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onEndEmulatorNavi, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteFailure, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGpsOpenStatus, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteSuccess, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGpsSignaChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviSettingChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviCancel, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviComplete, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviViewLoaded, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviBackClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onScanViewButtonClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapViewModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapViewTrackingModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLockMap, RCTBubblingEventBlock)

RCT_CUSTOM_VIEW_PROPERTY(layoutVisible, BOOL, AMapRideNaviView) {
    view.showUIElements = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(moreButtonVisible, BOOL, AMapRideNaviView) {
    view.showMoreButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(turnArrowVisible, BOOL, AMapRideNaviView) {
    view.showTurnArrow = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(browseButtonVisible, BOOL, AMapRideNaviView) {
    view.showBrowseRouteButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(compassVisible, BOOL, AMapRideNaviView) {
    view.showCompass = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(scaleVisible, BOOL, AMapRideNaviView) {
    view.showScale = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(trackingMode, NSInteger, AMapRideNaviView) {
    view.trackingMode = (AMapNaviViewTrackingMode)[RCTConvert NSInteger:json];
}
RCT_CUSTOM_VIEW_PROPERTY(screenAlwaysBright, BOOL, AMapRideNaviView) {
    [AMapNaviRideManager sharedInstance].screenAlwaysBright = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(startMarkerIcon, UIImage, AMapRideNaviView) {
    view.startPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(endMarkerIcon, UIImage, AMapRideNaviView) {
    view.endPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(carMarkerIcon, UIImage, AMapRideNaviView) {
    view.carImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(fourCornersIcon, UIImage, AMapRideNaviView) {
    view.carCompassImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(tilt, CGFloat, AMapRideNaviView) {
    view.cameraDegree = [RCTConvert CGFloat:json];
}
RCT_CUSTOM_VIEW_PROPERTY(showMode, NSInteger, AMapRideNaviView) {
    view.showMode = (AMapNaviRideViewShowMode)[RCTConvert NSInteger:json];
}
RCT_CUSTOM_VIEW_PROPERTY(navi, RideNaviParams, AMapNaviView) {
    RideNaviParams* params = [RCTConvert RideNaviParams: json];
    if(params == nil) {
        return;
    }
    if(params.to == nil) {
        return;
    }
    if([params.to isKindOfClass:[AMapNaviPoint class]]) {
        if(params.from != nil) {
            [[AMapNaviRideManager sharedInstance] calculateRideRouteWithStartPoint:params.from
                                                                            endPoint:params.to];
        } else {
            [[AMapNaviRideManager sharedInstance] calculateRideRouteWithEndPoint:params.to];
        }
        
    } else if([params.to isKindOfClass:[AMapNaviPOIInfo class]]) {
        [[AMapNaviRideManager sharedInstance] calculateRideRouteWithStartPOIInfo:params.from
                                                                        endPOIInfo:params.to
                                                                   strategy:params.strategy];
    }
}

RCT_EXPORT_METHOD(startNavi:(nonnull NSNumber *)reactTag type:(NSInteger)type speed:(NSInteger)speed) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        switch (type) {
            case 1:
                [[AMapNaviRideManager sharedInstance] startGPSNavi];
                break;
            case 2:
                [[AMapNaviRideManager sharedInstance] setEmulatorNaviSpeed:(int)speed];
                [[AMapNaviRideManager sharedInstance] startEmulatorNavi];
                break;
            default:
                break;
        }
    }];
}

RCT_EXPORT_METHOD(stopNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviRideManager sharedInstance] stopNavi];
    }];
}

RCT_EXPORT_METHOD(pauseNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviRideManager sharedInstance] pauseNavi];
    }];
}

RCT_EXPORT_METHOD(resumeNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviRideManager sharedInstance] resumeNavi];
    }];
}

RCT_EXPORT_METHOD(startGPS:(nonnull NSNumber *)reactTag) {
}


RCT_EXPORT_METHOD(stopGPS:(nonnull NSNumber *)reactTag) {
}

#pragma mark - AMapNavirideView Delegate
- (void)rideViewCloseButtonClicked:(AMapNaviRideView *)rideView {
    if(_rideView.onNaviBackClick) {
        _rideView.onNaviBackClick(nil);
    }
}

/**
 * @brief 导航界面更多按钮点击时的回调函数
 * @param rideView 骑行导航界面
 */
- (void)rideViewMoreButtonClicked:(AMapNaviRideView *)rideView {
}

/**
 * @brief 导航界面转向指示View点击时的回调函数
 * @param rideView 骑行导航界面
 */
- (void)rideViewTrunIndicatorViewTapped:(AMapNaviRideView *)rideView {
}

/**
 * @brief 导航界面显示模式改变后的回调函数
 * @param rideView 骑行导航界面
 * @param showMode 显示模式
 */
- (void)rideView:(AMapNaviRideView *)rideView didChangeShowMode:(AMapNaviRideViewShowMode)showMode {
    if(_rideView.onNaviMapModeChanged) {
        _rideView.onNaviMapModeChanged(@{@"mode": @(showMode)});
    }
}

/**
 * @brief 导航界面跟随模式改变后的回调函数. since 7.4.0
 * @param rideView 骑行导航界面
 * @param trackMode 跟随模式
 */
- (void)rideView:(AMapNaviRideView *)rideView didChangeTrackingMode:(AMapNaviViewTrackingMode)trackMode {
    if(_rideView.onNaviMapViewTrackingModeChanged) {
        _rideView.onNaviMapViewTrackingModeChanged(@{@"mode": @(trackMode)});
    }
}

/**
 * @brief 导航界面横竖屏切换后的回调函数. since 7.4.0
 * @param rideView 骑行导航界面
 * @param isLandscape 是否是横屏
 */
- (void)rideView:(AMapNaviRideView *)rideView didChangeOrientation:(BOOL)isLandscape {
}

#pragma mark - AMapNaviRideManager Delegate
/**
 * @brief 发生错误时,会调用代理的此方法
 * @param rideManager 骑行导航管理类
 * @param error 错误信息
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager error:(NSError *)error {
    if(_rideView.onInitNaviFailure) {
        _rideView.onInitNaviFailure(@{@"errorCode": [NSNumber numberWithInteger:error.code] });
    }
}

/**
 * @brief 骑行路径规划成功后的回调函数
 * @param rideManager 骑行导航管理类
 */
- (void)rideManagerOnCalculateRouteSuccess:(AMapNaviRideManager *)rideManager {
    if(_rideView.onCalculateRouteSuccess) {
        _rideView.onCalculateRouteSuccess(@{@"errorCode": @0, @"errorDetail": @"success", @"errorDescription": @"", @"routeId": rideManager.naviRouteIDs });
    }
}

/**
 * @brief 骑行路径规划失败后的回调函数. 从6.1.0版本起,算路失败后导航SDK只对外通知算路失败,SDK内部不再执行停止导航的相关逻辑.因此,当算路失败后,不会收到 driveManager:updateNaviMode: 回调; AMapNaviRideManager.naviMode 不会切换到 AMapNaviModeNone 状态, 而是会保持在 AMapNaviModeGPS or AMapNaviModeEmulator 状态
 * @param rideManager 骑行导航管理类
 * @param error 错误信息,error.code参照AMapNaviCalcRouteState
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager onCalculateRouteFailure:(NSError *)error {
    if(_rideView.onCalculateRouteFailure) {
        _rideView.onCalculateRouteFailure(@{@"errorCode":@(error.code),@"errorDetail":error.domain, @"errorDescription": error.localizedDescription});
    }
}

/**
 * @brief 启动导航后回调函数
 * @param rideManager 骑行导航管理类
 * @param naviMode 导航类型，参考AMapNaviMode
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager didStartNavi:(AMapNaviMode)naviMode {
    if(_rideView.onStartNavi) {
        _rideView.onStartNavi(nil);
    }
}

/**
 * @brief 出现偏航需要重新计算路径时的回调函数.偏航后将自动重新路径规划,该方法将在自动重新路径规划前通知您进行额外的处理.
 * @param rideManager 骑行导航管理类
 */
- (void)rideManagerNeedRecalculateRouteForYaw:(AMapNaviRideManager *)rideManager {
}

/**
 * @brief 导航播报信息回调函数
 * @param rideManager 骑行导航管理类
 * @param soundString 播报文字
 * @param soundStringType 播报类型,参考 AMapNaviSoundType. 注意：since 6.0.0 AMapNaviSoundType 只返回 AMapNaviSoundTypeDefault
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager playNaviSoundString:(NSString *)soundString soundStringType:(AMapNaviSoundType)soundStringType {
    [[SpeechSynthesizer sharedSpeechSynthesizer] speakString:soundString];
       if(_rideView.onGetNavigationText) {
           _rideView.onGetNavigationText(@{@"text": soundString});
       }
}

/**
 * @brief 模拟导航到达目的地停止导航后的回调函数
 * @param rideManager 骑行导航管理类
 */
- (void)rideManagerDidEndEmulatorNavi:(AMapNaviRideManager *)rideManager {
    if(_rideView.onEndEmulatorNavi) {
        _rideView.onEndEmulatorNavi(nil);
    }
}

/**
 * @brief 导航到达目的地后的回调函数
 * @param rideManager 骑行导航管理类
 */
- (void)rideManagerOnArrivedDestination:(AMapNaviRideManager *)rideManager {
    if(_rideView.onNaviComplete) {
        _rideView.onNaviComplete(nil);
    }
}

/**
 * @brief 卫星定位信号强弱回调函数. since 7.4.0
 * @param rideManager 骑行导航管理类
 * @param gpsSignalStrength 卫星定位信号强度类型,参考 AMapNaviGPSSignalStrength .
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager updateGPSSignalStrength:(AMapNaviGPSSignalStrength)gpsSignalStrength {
    if(_rideView.onGpsSignaChanged) {
        _rideView.onGpsSignaChanged(@{@"status": @(gpsSignalStrength)});
    }
}

#pragma mark - AMapNaviRideDataRepresentable Delegate
/**
 * @brief 导航模式更新回调
 * @param rideManager 骑行导航管理类
 * @param naviMode 导航模式,参考 AMapNaviMode 值
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager updateNaviMode:(AMapNaviMode)naviMode {
}

/**
 * @brief 路径ID更新回调
 * @param rideManager 骑行导航管理类
 * @param naviRouteID 导航路径ID
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager updateNaviRouteID:(NSInteger)naviRouteID {
}

/**
 * @brief 路径信息更新回调
 * @param rideManager 骑行导航管理类
 * @param naviRoute 路径信息,参考 AMapNaviRoute 类
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager updateNaviRoute:(nullable AMapNaviRoute *)naviRoute {
}

/**
 * @brief 导航信息更新回调
 * @param rideManager 骑行导航管理类
 * @param naviInfo 导航信息,参考 AMapNaviInfo 类
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager updateNaviInfo:(nullable AMapNaviInfo *)naviInfo {
}

/**
 * @brief 自车位置更新回调
 * @param rideManager 骑行导航管理类
 * @param naviLocation 自车位置信息,参考 AMapNaviLocation 类
 */
- (void)rideManager:(AMapNaviRideManager *)rideManager updateNaviLocation:(nullable AMapNaviLocation *)naviLocation {
    if(_rideView.onLocationChange) {
        _rideView.onLocationChange(@{
            @"accuracy":@(naviLocation.accuracy),
            @"altitude":@(naviLocation.altitude),
            @"bearing":@(naviLocation.heading),
            @"coord" : @{@"latitude":@(naviLocation.coordinate.latitude), @"longitude":@(naviLocation.coordinate.longitude)},
            @"curLinkIndex":@(naviLocation.currentLinkIndex),
            @"curStepIndex":@(naviLocation.currentSegmentIndex),
            @"speed":@(naviLocation.speed),
            @"time":[NSNumber numberWithDouble:[naviLocation.timestamp timeIntervalSinceReferenceDate]] });
    };
}
@end

#pragma mark - 步行导航ViewManager

@implementation AMapWalkNaviViewManager {
    AMapWalkNaviView *_walkView;
}

RCT_EXPORT_MODULE(AWalkNaviView)

-(UIView*)view {
    _walkView = [AMapWalkNaviView new];
    [_walkView setDelegate:self];
    
    [[AMapNaviWalkManager sharedInstance] setDelegate:self];
    [[AMapNaviWalkManager sharedInstance] addDataRepresentative:self];
    //将driveView添加为导航数据的Representative，使其可以接收到导航诱导数据
    [[AMapNaviWalkManager sharedInstance] addDataRepresentative:_walkView];
    [[AMapNaviWalkManager sharedInstance] setAllowsBackgroundLocationUpdates:YES];
    [[AMapNaviWalkManager sharedInstance] setPausesLocationUpdatesAutomatically:NO];
    
    return _walkView;
}

RCT_EXPORT_VIEW_PROPERTY(onInitNaviFailure, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onInitNaviSuccess, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onStartNavi, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLocationChange, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGetNavigationText, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onEndEmulatorNavi, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteFailure, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGpsOpenStatus, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteSuccess, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onGpsSignaChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviSettingChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviCancel, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviComplete, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviViewLoaded, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviBackClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onScanViewButtonClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapViewModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onNaviMapViewTrackingModeChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLockMap, RCTBubblingEventBlock)

RCT_CUSTOM_VIEW_PROPERTY(layoutVisible, BOOL, AMapWalkNaviView) {
    view.showUIElements = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(moreButtonVisible, BOOL, AMapWalkNaviView) {
    view.showMoreButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(turnArrowVisible, BOOL, AMapWalkNaviView) {
    view.showTurnArrow = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(browseButtonVisible, BOOL, AMapWalkNaviView) {
    view.showBrowseRouteButton = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(compassVisible, BOOL, AMapWalkNaviView) {
    view.showCompass = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(scaleVisible, BOOL, AMapWalkNaviView) {
    view.showScale = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(trackingMode, NSInteger, AMapWalkNaviView) {
    view.trackingMode = (AMapNaviViewTrackingMode)[RCTConvert NSInteger:json];
}
RCT_CUSTOM_VIEW_PROPERTY(screenAlwaysBright, NSInteger, AMapRideNaviView) {
    [AMapNaviWalkManager sharedInstance].screenAlwaysBright = [RCTConvert BOOL:json];
}
RCT_CUSTOM_VIEW_PROPERTY(startMarkerIcon, UIImage, AMapWalkNaviView) {
    view.startPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(endMarkerIcon, UIImage, AMapWalkNaviView) {
    view.endPointImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(carMarkerIcon, UIImage, AMapWalkNaviView) {
    view.carImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(fourCornersIcon, UIImage, AMapWalkNaviView) {
    view.carCompassImage = [RCTConvert UIImage:json];
}
RCT_CUSTOM_VIEW_PROPERTY(tilt, CGFloat, AMapWalkNaviView) {
    view.cameraDegree = [RCTConvert CGFloat:json];
}
RCT_CUSTOM_VIEW_PROPERTY(showMode, NSInteger, AMapWalkNaviView) {
    view.showMode = (AMapNaviWalkViewShowMode)[RCTConvert NSInteger:json];
}
RCT_CUSTOM_VIEW_PROPERTY(navi, RideNaviParams, AMapWalkNaviView) {
    NaviParams* params = [RCTConvert NaviParams: json];
    if(params == nil) {
        return;
    }
    if(params.to == nil || ![params.to isKindOfClass:[NSArray class]] || params.to.count == 0) {
        return;
    }
    if([params.to[0] isKindOfClass:[AMapNaviPoint class]]) {
        if(params.from != nil) {
            [[AMapNaviWalkManager sharedInstance] calculateWalkRouteWithStartPoints:params.from
                                                                          endPoints:params.to];
        } else {
            [[AMapNaviWalkManager sharedInstance] calculateWalkRouteWithEndPoints:params.to];
        }
        
    } else if([params.to[0] isKindOfClass:[AMapNaviPOIInfo class]]) {
        [[AMapNaviWalkManager sharedInstance] calculateWalkRouteWithStartPOIInfo:params.from[0]
                                                                      endPOIInfo:params.to[0]
                                                                        strategy:params.strategy];
    }
}

RCT_EXPORT_METHOD(startNavi:(nonnull NSNumber *)reactTag type:(NSInteger)type speed:(NSInteger)speed) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        switch (type) {
            case 1:
                [[AMapNaviWalkManager sharedInstance] startGPSNavi];
                break;
            case 2:
                [[AMapNaviWalkManager sharedInstance] setEmulatorNaviSpeed:(int)speed];
                [[AMapNaviWalkManager sharedInstance] startEmulatorNavi];
                break;
            default:
                break;
        }
    }];
}

RCT_EXPORT_METHOD(stopNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviWalkManager sharedInstance] stopNavi];
    }];
}

RCT_EXPORT_METHOD(pauseNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviWalkManager sharedInstance] pauseNavi];
    }];
}

RCT_EXPORT_METHOD(resumeNavi:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
        [[AMapNaviWalkManager sharedInstance] resumeNavi];
    }];
}

RCT_EXPORT_METHOD(startGPS:(nonnull NSNumber *)reactTag) {
}


RCT_EXPORT_METHOD(stopGPS:(nonnull NSNumber *)reactTag) {
}

#pragma mark - AMapNaviWalkView Delegate
- (void)walkViewCloseButtonClicked:(AMapNaviWalkView *)walkView {
    if(_walkView.onNaviBackClick) {
        _walkView.onNaviBackClick(nil);
    }
}

/**
 * @brief 导航界面更多按钮点击时的回调函数
 * @param walkView 步行导航界面
 */
- (void)walkViewMoreButtonClicked:(AMapNaviWalkView *)walkView {
}

/**
 * @brief 导航界面转向指示View点击时的回调函数
 * @param walkView 步行导航界面
 */
- (void)walkViewTrunIndicatorViewTapped:(AMapNaviWalkView *)walkView {
}

/**
 * @brief 导航界面显示模式改变后的回调函数
 * @param walkView 步行导航界面
 * @param showMode 显示模式
 */
- (void)rideView:(AMapNaviWalkView *)walkView didChangeShowMode:(AMapNaviWalkViewShowMode)showMode {
    if(_walkView.onNaviMapModeChanged) {
        _walkView.onNaviMapModeChanged(@{@"mode": @(showMode)});
    }
}

/**
 * @brief 导航界面跟随模式改变后的回调函数. since 7.4.0
 * @param walkView 步行导航界面
 * @param trackMode 跟随模式
 */
- (void)walkView:(AMapNaviWalkView *)walkView didChangeTrackingMode:(AMapNaviViewTrackingMode)trackMode {
    if(_walkView.onNaviMapViewTrackingModeChanged) {
        _walkView.onNaviMapViewTrackingModeChanged(@{@"mode": @(trackMode)});
    }
}

/**
 * @brief 导航界面横竖屏切换后的回调函数. since 7.4.0
 * @param walkView 步行导航界面
 * @param isLandscape 是否是横屏
 */
- (void)walkView:(AMapNaviRideView *)walkView didChangeOrientation:(BOOL)isLandscape {
}

#pragma mark - AMapNaviRideManager Delegate
/**
 * @brief 发生错误时,会调用代理的此方法
 * @param walkManager 步行导航管理类
 * @param error 错误信息
 */
- (void)walkManager:(AMapNaviWalkManager *)walkManager error:(NSError *)error {
    if(_walkView.onInitNaviFailure) {
        _walkView.onInitNaviFailure(@{@"errorCode": [NSNumber numberWithInteger:error.code] });
    }
}

/**
 * @brief 骑行路径规划成功后的回调函数
 * @param walkManager 步行导航管理类
 */
- (void)walkManagerOnCalculateRouteSuccess:(AMapNaviRideManager *)walkManager {
    if(_walkView.onCalculateRouteSuccess) {
        _walkView.onCalculateRouteSuccess(@{@"errorCode": @0, @"errorDetail": @"success", @"errorDescription": @"", @"routeId": walkManager.naviRouteIDs });
    }
}

/**
 * @brief 步行路径规划失败后的回调函数. 从6.1.0版本起,算路失败后导航SDK只对外通知算路失败,SDK内部不再执行停止导航的相关逻辑.因此,当算路失败后,不会收到 driveManager:updateNaviMode: 回调; AMapNaviRideManager.naviMode 不会切换到 AMapNaviModeNone 状态, 而是会保持在 AMapNaviModeGPS or AMapNaviModeEmulator 状态
 * @param walkManager 步行导航管理类
 * @param error 错误信息,error.code参照AMapNaviCalcRouteState
 */
- (void)walkManager:(AMapNaviWalkManager *)walkManager onCalculateRouteFailure:(NSError *)error {
    if(_walkView.onCalculateRouteFailure) {
        _walkView.onCalculateRouteFailure(@{@"errorCode":@(error.code),@"errorDetail":error.domain, @"errorDescription": error.localizedDescription});
    }
}

/**
 * @brief 启动导航后回调函数
 * @param walkManager 步行导航管理类
 * @param naviMode 导航类型，参考AMapNaviMode
 */
- (void)walkManager:(AMapNaviWalkManager *)walkManager didStartNavi:(AMapNaviMode)naviMode {
    if(_walkView.onStartNavi) {
        _walkView.onStartNavi(nil);
    }
}

/**
 * @brief 出现偏航需要重新计算路径时的回调函数.偏航后将自动重新路径规划,该方法将在自动重新路径规划前通知您进行额外的处理.
 * @param walkManager 步行导航管理类
 */
- (void)walkManagerNeedRecalculateRouteForYaw:(AMapNaviWalkManager *)walkManager {
}

/**
 * @brief 导航播报信息回调函数
 * @param walkManager 步行导航管理类
 * @param soundString 播报文字
 * @param soundStringType 播报类型,参考 AMapNaviSoundType. 注意：since 6.0.0 AMapNaviSoundType 只返回 AMapNaviSoundTypeDefault
 */
- (void)walkManager:(AMapNaviWalkManager *)walkManager playNaviSoundString:(NSString *)soundString soundStringType:(AMapNaviSoundType)soundStringType {
    [[SpeechSynthesizer sharedSpeechSynthesizer] speakString:soundString];
       if(_walkView.onGetNavigationText) {
           _walkView.onGetNavigationText(@{@"text": soundString});
       }
}

/**
 * @brief 模拟导航到达目的地停止导航后的回调函数
 * @param walkManager 步行导航管理类
 */
- (void)walkManagerDidEndEmulatorNavi:(AMapNaviWalkManager *)walkManager {
    if(_walkView.onEndEmulatorNavi) {
        _walkView.onEndEmulatorNavi(nil);
    }
}

/**
 * @brief 导航到达目的地后的回调函数
 * @param walkManager 步行导航管理类
 */
- (void)walkManagerOnArrivedDestination:(AMapNaviWalkManager *)walkManager {
    if(_walkView.onNaviComplete) {
        _walkView.onNaviComplete(nil);
    }
}

/**
 * @brief 卫星定位信号强弱回调函数. since 7.4.0
 * @param walkManager 步行导航管理类
 * @param gpsSignalStrength 卫星定位信号强度类型,参考 AMapNaviGPSSignalStrength .
 */
- (void)walkManager:(AMapNaviWalkManager *)walkManager updateGPSSignalStrength:(AMapNaviGPSSignalStrength)gpsSignalStrength {
    if(_walkView.onGpsSignaChanged) {
        _walkView.onGpsSignaChanged(@{@"status": @(gpsSignalStrength)});
    }
}

#pragma mark - AMapNaviRideDataRepresentable Delegate
/**
 * @brief 导航模式更新回调
 * @param walkManager 步行导航管理类
 * @param naviMode 导航模式,参考 AMapNaviMode 值
 */
- (void)walkManager:(AMapNaviRideManager *)walkManager updateNaviMode:(AMapNaviMode)naviMode {
}

/**
 * @brief 路径ID更新回调
 * @param walkManager 步行导航管理类
 * @param naviRouteID 导航路径ID
 */
- (void)walkManager:(AMapNaviRideManager *)walkManager updateNaviRouteID:(NSInteger)naviRouteID {
}

/**
 * @brief 路径信息更新回调
 * @param walkManager 步行导航管理类
 * @param naviRoute 路径信息,参考 AMapNaviRoute 类
 */
- (void)walkManager:(AMapNaviRideManager *)walkManager updateNaviRoute:(nullable AMapNaviRoute *)naviRoute {
}

/**
 * @brief 导航信息更新回调
 * @param walkManager 步行导航管理类
 * @param naviInfo 导航信息,参考 AMapNaviInfo 类
 */
- (void)walkManager:(AMapNaviRideManager *)walkManager updateNaviInfo:(nullable AMapNaviInfo *)naviInfo {
}

/**
 * @brief 自车位置更新回调
 * @param walkManager 步行导航管理类
 * @param naviLocation 自车位置信息,参考 AMapNaviLocation 类
 */
- (void)walkManager:(AMapNaviRideManager *)walkManager updateNaviLocation:(nullable AMapNaviLocation *)naviLocation {
    if(_walkView.onLocationChange) {
        _walkView.onLocationChange(@{
            @"accuracy":@(naviLocation.accuracy),
            @"altitude":@(naviLocation.altitude),
            @"bearing":@(naviLocation.heading),
            @"coord" : @{@"latitude":@(naviLocation.coordinate.latitude), @"longitude":@(naviLocation.coordinate.longitude)},
            @"curLinkIndex":@(naviLocation.currentLinkIndex),
            @"curStepIndex":@(naviLocation.currentSegmentIndex),
            @"speed":@(naviLocation.speed),
            @"time":[NSNumber numberWithDouble:[naviLocation.timestamp timeIntervalSinceReferenceDate]] });
    };
}
@end
