0

I can successfully hide the Mapbox logoView in an MGLMapView, but when I try to do the same for the NavigationMapView of a NavigationViewController, it doesn't work. Here's what I'm trying:

@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)
    }
}

As you can see, the logo still shows up (bottom left).

enter image description here

What am I doing wrong?

Addendum: here's a bit of the main MGLMapView, showing that you can hide the logo there, as demonstrated in the example app in the SDK.

enter image description here

Dylan
  • 2,315
  • 2
  • 20
  • 33
  • 1
    Based on Mapbox attribution this seems not to be possible docs.mapbox.com/help/how-mapbox-works/attribution as long as you are using design, templates or data from mapbox. Having said so, this could be more a legal warning than a technical constraint that you can override with a hack. – jscastro Jul 19 '20 at 09:40
  • It is confusing, given that the example included with the SDK demonstrates hiding the logo in the main MGLMapView: `mapView.logoView.isHidden = true`. It's just not working in the NavigationMapView for some reason. – Dylan Jul 19 '20 at 18:52
  • yes, it is. I read also that it depends on the plan, which could be a tweak that is making your code not to work, AFAIK unless you are on the Standard or Premium pricing plans then the MapBox logo is required according to the terms of service. – jscastro Jul 20 '20 at 11:05
  • I've updated my post with an addendum showing that the logo hiding is working for MGLMapView on my plan, just not the NavigationMapView. – Dylan Jul 20 '20 at 17:46
  • 1
    Hey @Dylan **Try this it's working for me.** `navigationViewController.mapView?.logoView.isHidden = true` `navigationViewController.mapView?.logoView.alpha = 0` – Mitesh Mewada Jul 18 '21 at 12:13
  • Great catch @MiteshMewada. The alpha = 0 did it for me. – haste Jun 30 '22 at 10:23

0 Answers0