Skip to content

Commit d8fad34

Browse files
committed
Add NavigationViewViewController skeleton example.
1 parent c4c08de commit d8fad34

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Navigation-Examples/Constants.swift

+7
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,12 @@ let listOfExamples: [NamedController] = [
181181
controller: CustomRoutingProviderViewController.self,
182182
storyboard: nil,
183183
pushExampleToViewController: true
184+
),
185+
(
186+
name: "Navigation View",
187+
description: "Demonstrates how to use NavigationView.",
188+
controller: NavigationViewViewController.self,
189+
storyboard: nil,
190+
pushExampleToViewController: true
184191
)
185192
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import UIKit
2+
import MapboxCoreNavigation
3+
import MapboxNavigation
4+
import MapboxDirections
5+
6+
class NavigationViewViewController: UIViewController {
7+
8+
var navigationView: NavigationView!
9+
10+
override func viewDidLoad() {
11+
super.viewDidLoad()
12+
13+
navigationView = NavigationView(frame: view.bounds)
14+
navigationView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
15+
16+
let navigationViewportDataSource = NavigationViewportDataSource(navigationView.navigationMapView.mapView,
17+
viewportDataSourceType: .raw)
18+
navigationView.navigationMapView.navigationCamera.viewportDataSource = navigationViewportDataSource
19+
navigationView.navigationMapView.navigationCamera.follow()
20+
21+
view.addSubview(navigationView)
22+
23+
navigationView.bottomBannerContainerView.isHidden = false
24+
navigationView.bottomBannerContainerView.heightAnchor.constraint(equalToConstant: 150.0).isActive = true
25+
navigationView.bottomBannerContainerView.backgroundColor = .white
26+
navigationView.isBottomBannerContainerViewExpandable = true
27+
navigationView.bottomBannerContainerViewOffset = 50.0
28+
29+
navigationView.topBannerContainerView.isHidden = false
30+
navigationView.topBannerContainerView.heightAnchor.constraint(equalToConstant: 50.0).isActive = true
31+
navigationView.topBannerContainerView.backgroundColor = .white
32+
}
33+
}

0 commit comments

Comments
 (0)