0

我可以成功地将 Mapbox 隐藏在 alogoViewMGLMapView,但是当我尝试对NavigationMapViewa执行相同操作时NavigationViewController,它不起作用。这是我正在尝试的:

@IBAction func startNavigation(_ sender: Any) {
    guard let response = response, let route = response.routes?.first, case let .route(routeOptions) = response.options else { return }
    let styles = [DayStyle()]
    let options = NavigationOptions(styles: styles, navigationService: navigationService(route: route, options: routeOptions))
    let navigationViewController = NavigationViewController(for: route, routeOptions: routeOptions, navigationOptions: options)
    navigationViewController.delegate = self

    presentAndRemoveMapview(navigationViewController, completion: beginCarPlayNavigation)
}

func navigationService(route: Route, options: RouteOptions) -> NavigationService {
    let mode: SimulationMode = .onPoorGPS
    return MapboxNavigationService(route: route, routeOptions: options, directions: Settings.directions, simulating: mode)
}

func presentAndRemoveMapview(_ navigationViewController: NavigationViewController, completion: CompletionHandler?) {
    navigationViewController.modalPresentationStyle = .fullScreen
    activeNavigationViewController = navigationViewController
    
    present(navigationViewController, animated: true) {
        activeNavigationViewController!.mapView!.logoView.isHidden = true
        completion?()
    }
}

func beginCarPlayNavigation() {
    let delegate = UIApplication.shared.delegate as? AppDelegate

    if #available(iOS 12.0, *),
        let service = activeNavigationViewController?.navigationService,
        let location = service.router.location {
        delegate?.carPlayManager.beginNavigationWithCarPlay(using: location.coordinate, navigationService: service)
    }
}

如您所见,徽标仍然显示(左下角)。

在此处输入图像描述

我究竟做错了什么?

附录:这里有一些主要的 MGLMapView,显示您可以在那里隐藏徽标,如 SDK 中的示例应用程序所示。

在此处输入图像描述

4

0 回答 0