ios - 导航模式下不显示文本说明 (Mapbox iOS)

标签 ios objective-c mapbox

在导航模式下,步骤说明文本不会显示(据我测试,语音说明也不会出现)。这是我在获取路线时调用的函数:

- (void)startNavigation:(MBRoute *)route {
MBNavigationLocationManager *locationManager = [[MBNavigationLocationManager alloc] init];
MBNavigationViewController *controller = [[MBNavigationViewController alloc] initWithRoute:route directions:[MBDirections sharedDirections] style:nil locationManager:locationManager];
[self presentViewController:controller animated:YES completion:^{ NSString *locationURL = [NSString stringWithFormat:@"https://DBNAME.firebaseio.com/realtime-location"];
    FIRDatabaseReference *geofireRef = [[FIRDatabase database] referenceFromURL:locationURL];
    GeoFire *geoFire = [[GeoFire alloc] initWithFirebaseRef:geofireRef];
    CLLocation *center = [[CLLocation alloc] initWithLatitude:self.currentLocation.coordinate.latitude longitude:self.currentLocation.coordinate.longitude];
    GFCircleQuery *circleQuery = [geoFire queryAtLocation:center withRadius:1.0];
    FIRDatabaseHandle queryEntered = [circleQuery observeEventType:GFEventTypeKeyEntered withBlock:^(NSString *key, CLLocation *location) {
        if (![key isEqualToString:self.carID]) {
            for (MGLPointAnnotation *annotation in controller.mapView.annotations) {
                if ([annotation.title isEqualToString:key]) {
                    break;
                } else {
                    MGLPointAnnotation *point = [[MGLPointAnnotation alloc] init];
                    point.coordinate = location.coordinate;
                    point.title = key;
                    [controller.mapView addAnnotation:point];
                    NSLog(@"Added new surrounding annotation %@", key);
                }
            }
        }
    }];

    FIRDatabaseHandle queryMoved = [circleQuery observeEventType:GFEventTypeKeyMoved withBlock:^(NSString *key, CLLocation *location) {
        if (![key isEqualToString:self.carID]) {
            for (MGLPointAnnotation *annotation in controller.mapView.annotations) {
                if ([annotation.title isEqualToString:key]) {
                    [controller.mapView removeAnnotation:annotation];

                    MGLPointAnnotation *point = [[MGLPointAnnotation alloc] init];
                    point.coordinate = location.coordinate;
                    point.title = key;
                    [controller.mapView addAnnotation:point];
                    NSLog(@"Updated surrounding annotations %@", key);
                }
            }
        }
    }];
}];

self.navController = controller;
UIButton *cautionButton = [UIButton buttonWithType:UIButtonTypeCustom];
cautionButton.frame = CGRectMake(3, self.view.frame.size.height-122, 45, 39);
UIImage *buttonImage = [UIImage imageNamed:@"caution"];
[cautionButton setImage:buttonImage forState:UIControlStateNormal];
[cautionButton addTarget:self action:@selector(reportCaution) forControlEvents:UIControlEventTouchUpInside];
[controller.view addSubview:cautionButton];

截图:

img_5652 img_5651

这是我使用的 Mapbox 相关 pod 的版本。据我所知,它们是最新的版本:

 - Mapbox-iOS-SDK (3.7.2)
  - MapboxCoreNavigation (0.12.0):
    - MapboxDirections.swift (~> 0.15)
    - MapboxMobileEvents (~> 0.2)
    - Turf (~> 0.0.4)
  - MapboxDirections.swift (0.15.1):
    - Polyline (~> 4.2)
  - MapboxMobileEvents (0.2.10)
  - MapboxNavigation (0.12.0):
    - AWSPolly (~> 2.6)
    - Mapbox-iOS-SDK (~> 3.6)
    - MapboxCoreNavigation (= 0.12.0)
    - SDWebImage (~> 4.1)
    - Solar (~> 2.1)
    - Turf (~> 0.0.4)
  - Masonry (1.1.0)
  - MBProgressHUD (0.9.2)

最佳答案

通过更改calculateDirectionsWithOptions的路线选项解决了这个问题(我已经有includeSteps = YES):

options.includesSpokenInstructions = YES;
options.includesVisualInstructions = YES;

关于ios - 导航模式下不显示文本说明 (Mapbox iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47947428/

相关文章:

swift - MapBox IOS SDK swift : how to show the user annotations from specific zoomLevel without delete and add again?

javascript - 来自 geoJSON 的 Mapbox 标记未出现在 IE9 中

javascript - Mapbox-gl-directions 事件不会触发

IOS 相当于 Android 选择器

ios - 以编程方式实现的约束与 Storyboard 中的约束的工作方式不同

ios - 如何动画一个接一个的 UILabel

iphone - 没有边框的 UIBarButtonItem

ios - Grand Central Dispatch,不确定我是否完全理解这一点,这就是我的使用方式

ios - 回到 Swift 2 中的 Facebook 问题

iphone - 在 Restkit (iPhone) 中使用 Json 响应