Skip to content

Commit c85302d

Browse files
author
Bobby Sudekum
authored
Merge pull request #1406 from mapbox/navigation/arrival_banners_enhancement
Changes to adopt the named arrival instructions from Directions API
2 parents 536a017 + 5cd9728 commit c85302d

8 files changed

+13
-18
lines changed

Cartfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 4.0
2-
github "mapbox/MapboxDirections.swift" ~> 0.20.0
2+
github "mapbox/MapboxDirections.swift" ~> 0.21.0
33
github "mapbox/turf-swift" ~> 0.1
44
github "mapbox/mapbox-events-ios" ~> 0.4
55
github "ceeK/Solar" ~> 2.1.0

Cartfile.resolved

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "4.0.1"
22
github "ceeK/Solar" "2.1.0"
3-
github "mapbox/MapboxDirections.swift" "v0.20.0"
3+
github "mapbox/MapboxDirections.swift" "v0.21.0"
44
github "mapbox/mapbox-events-ios" "v0.4.0"
55
github "mapbox/mapbox-voice-swift" "v0.0.1"
66
github "mapbox/turf-swift" "v0.1.1"

Examples/Swift/ViewController.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ class ViewController: UIViewController, MGLMapViewDelegate, CLLocationManagerDel
154154
multipleStopsAction.isEnabled = false
155155
}
156156

157+
157158
let coordinates = mapView.convert(tap.location(in: mapView), toCoordinateFrom: mapView)
158-
let waypoint = Waypoint(coordinate: coordinates)
159+
// Note: The destination name can be modified. The value is used in the top banner when arriving at a destination.
160+
let destinationName = "Dropped Pin #\(waypoints.endIndex + 1)"
161+
let waypoint = Waypoint(coordinate: coordinates, name: destinationName)
159162
waypoint.coordinateAccuracy = -1
160163
waypoints.append(waypoint)
161164

@@ -202,7 +205,8 @@ class ViewController: UIViewController, MGLMapViewDelegate, CLLocationManagerDel
202205
guard waypoints.count > 0 else { return }
203206
guard let mapView = mapView else { return }
204207

205-
let userWaypoint = Waypoint(location: mapView.userLocation!.location!, heading: mapView.userLocation?.heading, name: "user")
208+
let departureName = "User location"
209+
let userWaypoint = Waypoint(location: mapView.userLocation!.location!, heading: mapView.userLocation?.heading, name: departureName)
206210
waypoints.insert(userWaypoint, at: 0)
207211

208212
let options = NavigationRouteOptions(waypoints: waypoints)

MapboxCoreNavigation.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Pod::Spec.new do |s|
4040
s.requires_arc = true
4141
s.module_name = "MapboxCoreNavigation"
4242

43-
s.dependency "MapboxDirections.swift", "~> 0.20.0"
43+
s.dependency "MapboxDirections.swift", "~> 0.21.0"
4444
s.dependency "MapboxMobileEvents", "~> 0.4"
4545
s.dependency "Turf", "~> 0.1"
4646

MapboxCoreNavigationTests/BridgingTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ - (void)testUpdateRoute {
2121
MBWaypoint *wp2 = [[MBWaypoint alloc] initWithCoordinate:CLLocationCoordinate2DMake(37.7727, -122.433378) coordinateAccuracy:0 name:@"wp2"];
2222
NSArray<MBWaypoint *> *waypoints = @[wp1, wp2];
2323
MBNavigationRouteOptions *options = [[MBNavigationRouteOptions alloc] initWithWaypoints:waypoints profileIdentifier:MBDirectionsProfileIdentifierAutomobileAvoidingTraffic];
24-
MBRoute *route = [[MBRoute alloc] initWithJson:routeDict waypoints:waypoints routeOptions:options];
24+
MBRoute *route = [[MBRoute alloc] initWithJSON:routeDict waypoints:waypoints routeOptions:options];
2525
route.accessToken = @"garbage";
2626
XCTAssertNotNil(route);
2727
MBEventsManagerSpy *eventsManager = [[MBEventsManagerSpy alloc] init];

MapboxNavigation-Documentation.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Pod::Spec.new do |s|
4343
s.requires_arc = true
4444
s.module_name = "MapboxNavigation"
4545

46-
s.dependency "MapboxDirections.swift", "~> 0.19.1"
46+
s.dependency "MapboxDirections.swift", "~> 0.21.0"
4747
s.dependency "Mapbox-iOS-SDK", "~> 4.0"
4848
s.dependency "MapboxMobileEvents", "~> 0.4"
4949
s.dependency "Solar", "~> 2.1"

MapboxNavigation/ManeuverView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ open class ManeuverView: UIView {
8383
ManeuversStyleKit.drawFork(frame: bounds, resizing: resizing, primaryColor: primaryColor, secondaryColor: secondaryColor)
8484
flip = [.left, .slightLeft, .sharpLeft].contains(direction)
8585
case .takeRoundabout, .turnAtRoundabout, .takeRotary:
86-
ManeuversStyleKit.drawRoundabout(frame: bounds, resizing: resizing, primaryColor: primaryColor, secondaryColor: secondaryColor, roundabout_angle: CGFloat(visualInstruction.primaryInstruction.degrees))
86+
ManeuversStyleKit.drawRoundabout(frame: bounds, resizing: resizing, primaryColor: primaryColor, secondaryColor: secondaryColor, roundabout_angle: CGFloat(visualInstruction.primaryInstruction.finalHeading))
8787
flip = visualInstruction.drivingSide == .left
8888

8989
case .arrive:

MapboxNavigation/StepsViewController.swift

+1-10
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ extension StepsViewController: UITableViewDataSource {
234234
return cell
235235
}
236236

237-
func instructionForArrivalInstruction(text: String?) -> VisualInstruction {
238-
let component = VisualInstructionComponent(type: .text, text: text, imageURL: nil, abbreviation: nil, abbreviationPriority: NSNotFound)
239-
let instruction = VisualInstruction(text: nil, maneuverType: .arrive, maneuverDirection: .none, textComponents: [component])
240-
return instruction
241-
}
242-
243237
public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
244238
updateCell(cell as! StepTableViewCell, at: indexPath)
245239
}
@@ -249,13 +243,10 @@ extension StepsViewController: UITableViewDataSource {
249243
cell.instructionsView.secondaryLabel.viewForAvailableBoundsCalculation = cell
250244

251245
let step = sections[indexPath.section][indexPath.row]
252-
253-
let leg = routeProgress.route.legs[indexPath.section]
254-
let arrivalSecondaryInstruction = leg.destination.name
255246

256247
if let instructions = step.instructionsDisplayedAlongStep?.last {
257248
cell.instructionsView.set(instructions)
258-
cell.instructionsView.secondaryLabel.instruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? instructionForArrivalInstruction(text: arrivalSecondaryInstruction) : instructions.secondaryInstruction
249+
cell.instructionsView.secondaryLabel.instruction = instructions.secondaryInstruction
259250
}
260251
cell.instructionsView.distance = step.distance
261252

0 commit comments

Comments
 (0)