在导航模式下,步骤说明文本没有显示(据我测试,语音指令也没有出现)。这是我获得路线时调用的函数:
- (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];
}
截图:
以下是我正在使用的与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)
答案 0 :(得分:1)
通过更改calculateDirectionsWithOptions的路由选项来解决这个问题(我已经有了includesSteps = YES):
{{1}}