Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add waypoint handling #270

Merged
merged 71 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
92a1d30
Add waypoint handling
Jun 8, 2017
d009fff
more waypoints
Jun 9, 2017
c33b154
Use sections
Jun 9, 2017
c6dabb3
clear map
Jun 11, 2017
2c6524a
remove destination
Jun 13, 2017
382ede6
Updates
Jun 13, 2017
52b867d
remove
Jun 13, 2017
315a681
use name
Jun 16, 2017
cbe2ce1
return waypoint when arriving at each waypoint
Jun 19, 2017
988dfd0
Merge branch 'master' into waypoints
Jun 20, 2017
753814a
update
Jun 20, 2017
275b973
Merge branch 'master' into waypoints
Jul 6, 2017
13b4ad1
update example
Jul 6, 2017
ebfa33f
Merge branch 'master' into waypoints
Jul 25, 2017
204eeff
update
Jul 25, 2017
85684aa
remove arg
Jul 26, 2017
e88e2b1
localize
Jul 26, 2017
d7828aa
remove comma
Jul 27, 2017
9f10ad9
Merge branch 'master' into waypoints
Jul 27, 2017
082c44e
whitespace
Jul 31, 2017
40d58cd
fix
Jul 31, 2017
2c26fe9
whitespace
Jul 31, 2017
6340c58
Merge branch 'master' into waypoints
Jul 31, 2017
f052af0
Style, confirm next
Jul 31, 2017
0ab7e26
move
Jul 31, 2017
3e95e9c
remove unused
Jul 31, 2017
8eb79fa
Merge branch 'master' into waypoints
Aug 3, 2017
ee9df0f
Remove waypoint once done
Aug 4, 2017
bb73e66
Merge branch 'master' into waypoints
Aug 7, 2017
edd881b
add clear button
Aug 7, 2017
b0247d6
Merge branch 'master' into waypoints
Aug 8, 2017
4369010
Make waypoint customizable
Aug 9, 2017
3c568c4
fix
Aug 9, 2017
f0ab02f
Improve names
Aug 9, 2017
0c5ae6f
Add back
Aug 9, 2017
cfa67b6
add back
Aug 9, 2017
7144f59
move around
Aug 9, 2017
087de57
remove
Aug 9, 2017
7b15853
remove
Aug 9, 2017
ba54bd0
Merge branch 'master' into waypoints
Aug 9, 2017
4934ad0
move arrow
Aug 9, 2017
84c3c41
add back
Aug 9, 2017
2f5602f
Merge branch 'master' into waypoints
Aug 10, 2017
8b41be7
Change names
Aug 10, 2017
5907c9a
Add translation
Aug 10, 2017
3f0e8ca
Wow, rename
Aug 10, 2017
deda53a
Update
Aug 10, 2017
20bc71e
increment
Aug 10, 2017
3f8214f
False
Aug 10, 2017
4305493
Add translation, update
Aug 11, 2017
b2562d6
fix
Aug 11, 2017
cb66468
Merge branch 'master' into waypoints
Aug 11, 2017
a1d4cbe
Merge branch 'master' into waypoints
Aug 14, 2017
8e17b03
change api
Aug 14, 2017
771dbca
remove
Aug 14, 2017
5b66ffd
Merge branch 'master' into waypoints
Aug 14, 2017
5ebb998
document
Aug 14, 2017
e177cd2
Consistent
Aug 14, 2017
1ab08d5
Merge branch 'master' into waypoints
Aug 16, 2017
1286a2e
remove annotations
Aug 16, 2017
9b2f21b
Merge branch 'master' into waypoints
Aug 17, 2017
306e55a
Merge branch 'master' into waypoints
Aug 17, 2017
518d535
Merge branch 'master' into waypoints
Aug 21, 2017
8ef4112
Merge branch 'master' into waypoints
Aug 22, 2017
f0dc3d5
Merge branch 'master' into waypoints
Aug 23, 2017
e5eb660
Always update
Aug 23, 2017
b9b3555
Flip
Aug 24, 2017
84a1f34
Update
Aug 24, 2017
de69c03
Make bolder
Aug 24, 2017
5995b2f
darker gray
Aug 24, 2017
26fec4b
Update docs
Aug 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Examples/Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ViewController: UIViewController, MGLMapViewDelegate {
alertController.addAction(UIAlertAction(title: "Styled UI", style: .default, handler: { (action) in
self.startStyledNavigation()
}))
if waypoints.count > 2 {
if self.waypoints.count > 2 {
alertController.addAction(UIAlertAction(title: "Multiple Stops", style: .default, handler: { (action) in
self.startMultipleWaypoints()
}))
Expand Down Expand Up @@ -154,7 +154,7 @@ class ViewController: UIViewController, MGLMapViewDelegate {
self?.currentRoute = route

// Open method for adding and updating the route line
self?.mapView.showRoute(route, legIndex: 0)
self?.mapView.showRoute(route)
}
}

Expand Down
24 changes: 12 additions & 12 deletions MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class NavigationMapView: MGLMapView {
let arrowLayerStrokeIdentifier = "arrowStrokeLayer"
let arrowCasingSymbolLayerIdentifier = "arrowCasingSymbolLayer"
let arrowSymbolSourceIdentifier = "arrowSymbolSource"
let isOpaqueIdentifier = "isOpaqueIdentifier"
let isCurrentLeg = "isCurrentLeg"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name isCurrentLeg implies that it’s a Boolean. Since this string is being used as an attribute name, call it currentLegAttribute but give it the value isCurrentLeg.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#270 (comment) got collapsed for some reason: the name isCurrentLeg implies that it’s a Boolean. Since this string is being used as an attribute name, call it currentLegAttribute but give it the value isCurrentLeg.


let routeLineWidthAtZoomLevels: [Int: MGLStyleValue<NSNumber>] = [
10: MGLStyleValue(rawValue: 6),
Expand Down Expand Up @@ -80,7 +80,7 @@ open class NavigationMapView: MGLMapView {
/**
Adds or updates both the route line and the route line casing
*/
public func showRoute(_ route: Route, legIndex: Int?) {
public func showRoute(_ route: Route, legIndex: Int? = nil) {
guard let style = style else {
return
}
Expand Down Expand Up @@ -152,8 +152,8 @@ open class NavigationMapView: MGLMapView {

let source = navigationMapDelegate?.navigationMapView?(self, shapeFor: routeProgress.remainingWaypoints) ?? shape(for: Array(routeProgress.remainingWaypoints.dropLast()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s give this variable and s below more descriptive names.


if let s = style.source(withIdentifier: waypointSourceIdentifier) as? MGLShapeSource {
s.shape = source
if let waypointSource = style.source(withIdentifier: waypointSourceIdentifier) as? MGLShapeSource {
waypointSource.shape = source
} else {
let sourceShape = MGLShapeSource(identifier: waypointSourceIdentifier, shape: source, options: nil)
style.addSource(sourceShape)
Expand Down Expand Up @@ -204,9 +204,9 @@ open class NavigationMapView: MGLMapView {
let polyline = MGLPolylineFeature(coordinates: congestionSegment.0, count: UInt(congestionSegment.0.count))
polyline.attributes["congestion"] = String(describing: congestionSegment.1)
if let legIndex = legIndex {
polyline.attributes[isOpaqueIdentifier] = index != legIndex
polyline.attributes[isCurrentLeg] = index != legIndex
} else {
polyline.attributes[isOpaqueIdentifier] = false
polyline.attributes[isCurrentLeg] = index != 0
}
return polyline
}
Expand All @@ -227,9 +227,9 @@ open class NavigationMapView: MGLMapView {

let polyline = MGLPolylineFeature(coordinates: legCoordinates, count: UInt(legCoordinates.count))
if let legIndex = legIndex {
polyline.attributes[isOpaqueIdentifier] = index != legIndex
polyline.attributes[isCurrentLeg] = index != legIndex
} else {
polyline.attributes[isOpaqueIdentifier] = false
polyline.attributes[isCurrentLeg] = index != 0
}
linesPerLeg.append(polyline)
}
Expand All @@ -239,7 +239,7 @@ open class NavigationMapView: MGLMapView {

func shape(for waypoints: [Waypoint]) -> MGLShape? {
var features = [MGLPointFeature]()
let letters = (97...122).map({Character(UnicodeScalar($0))}).map { String(describing:$0).uppercased() }
let letters = String.localizedStringWithFormat(NSLocalizedString("ALPHABET", bundle: .mapboxNavigation, value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", comment: "Format string for alphabet;")).components(separatedBy: "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an actual separator like a space, because some locales may have multi-character letters in the alphabet, like “IJ” in Dutch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray semicolon at the end of the comment. Make sure to point out that each letter should be separated by a space.


for (waypointIndex, waypoint) in waypoints.enumerated() {
let feature = MGLPointFeature()
Expand Down Expand Up @@ -292,7 +292,7 @@ open class NavigationMapView: MGLMapView {
line.lineOpacity = MGLStyleValue(interpolationMode: .categorical, sourceStops: [
true: MGLStyleValue(rawValue: 0),
false: MGLStyleValue(rawValue: 1)
], attributeName: isOpaqueIdentifier, options: nil)
], attributeName: isCurrentLeg, options: nil)

line.lineJoin = MGLStyleValue(rawValue: NSValue(mglLineJoin: .round))

Expand Down Expand Up @@ -320,9 +320,9 @@ open class NavigationMapView: MGLMapView {
lineCasing.lineJoin = MGLStyleValue(rawValue: NSValue(mglLineJoin: .round))

lineCasing.lineOpacity = MGLStyleValue(interpolationMode: .categorical, sourceStops: [
true: MGLStyleValue(rawValue: 0.4),
true: MGLStyleValue(rawValue: 0.70),
false: MGLStyleValue(rawValue: 1)
], attributeName: isOpaqueIdentifier, options: nil)
], attributeName: isCurrentLeg, options: nil)

return lineCasing
}
Expand Down
5 changes: 4 additions & 1 deletion MapboxNavigation/Resources/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* Format string for and; */
/* Format string for alphabet; */
"ALPHABET" = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/* Format string for and; */
"AND" = "and";

/* Format for speech string after completing a maneuver and starting a new step; 1 = distance */
Expand Down