在HERE地图中实现语音导航

时间:2018-04-20 08:39:34

标签: ios objective-c here-api

我正在使用HERE地图在iOS(Objective-C)中构建基于地图的应用程序,并且是我的新手。我成功地实现了导航,但是我在实现导航语音指令方面遇到了麻烦。这是我的代码:

- (void) beginNavigationMethod {
    self.mapView.zoomLevel = 17.0;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didUpdatePositionForNavigation) name:NMAPositioningManagerDidUpdatePositionNotification object:[NMAPositioningManager sharedPositioningManager]];

    NMAVoiceCatalog *voiceCatalog = [NMAVoiceCatalog sharedVoiceCatalog];
    voiceCatalog.delegate = self;
    [voiceCatalog updateVoiceCatalog];

    [self.navigationManager startTurnByTurnNavigationWithRoute:self.route];
    [NMANavigationManager sharedNavigationManager].mapTrackingEnabled = YES;
    [NMANavigationManager sharedNavigationManager].mapTrackingAutoZoomEnabled = YES;
    [NMANavigationManager sharedNavigationManager].mapTrackingOrientation
    = NMAMapTrackingOrientationDynamic;
    [NMANavigationManager sharedNavigationManager].speedWarningEnabled = YES;
    NSError* error = [[NMANavigationManager sharedNavigationManager] startTurnByTurnNavigationWithRoute:self.route];
    NSLog(@"%@",error);
}

- (void)voiceCatalog:(nonnull NMAVoiceCatalog *)voiceCatalog didUpdateWithError:(nullable NSError *)error {
    NSLog(@"didUpdateWithError: %@",error);
}

我基本上不知道如何处理这个问题。我很抱歉这么天真。如果有人能指导我完成这件事,那将是一个很大的帮助。

2 个答案:

答案 0 :(得分:0)

您可以查看文档:{​​{3}}

否则,Android的示例在哪里:https://developer.here.com/documentation/ios-premium/topics/map-voice-instructions.html,如果您可以通过它,它会给您一个如何做到这一点的印象。

答案 1 :(得分:0)

请尝试此代码

 [[NMANavigationManager sharedNavigationManager] setVoicePackageMeasurementSystem:NMAMeasurementSystemImperialUS];
 [[NMAAudioManager sharedAudioManager] setDelegate:self];
 [[NMAAudioManager sharedAudioManager]setManagesAudioSession:NO];

这里是Map Delegate方法

 - (BOOL)audioManager:(NMAAudioManager *)audioManager shouldPlayOutput:(NMAAudioOutput *)output{  
       return true;
   }

项目设置 - >一般 - >功能 - >背景模式

enter image description here