diff --git a/CHANGELOG.md b/CHANGELOG.md index fb37bcb334..dab2e96227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,13 +28,11 @@ ### Other changes * `DistanceFormatter`, `ReplayLocationManager`, `SimulatedLocationManager`, `LanesView`, and `ManueverView` are now subclassable. ([#1345](https://github.com/mapbox/mapbox-navigation-ios/pull/1345])) -* Renamed methods on `NavigationMapViewDelegate` ([#1364](https://github.com/mapbox/mapbox-navigation-ios/pull/1364), [#1338](https://github.com/mapbox/mapbox-navigation-ios/pull/1338), [#1318](https://github.com/mapbox/mapbox-navigation-ios/pull/1318)): - - `NavigationMapViewDelegate.navigationMapView(_:shapeDescribingRoute:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:shapeDescribing:)`. - - `NavigationMapViewDelegate.navigationMapView(_:shapeDescribingWaypoints:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeDescribingRoute:)`. - - `NavigationMapViewDelegate.navigationMapView(_:shapeDescribingWaypoints:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:shapeFor:legIndex:)`. - - `NavigationMapViewDelegate.navigationMapView(_:imageForAnnotation:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:imageFor:)`. - - `NavigationMapViewDelegate.navigationMapView(_:viewForAnnotation:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:viewFor:)`. - - `NavigationViewControllerDelegate.navigationViewControllerDidCancelNavigation(_:)` to `NavigationViewControllerDelegate.navigationViewControllerDidDismiss(_:byCanceling:)` +* Renamed several `NavigationMapViewDelegate` methods ([#1364](https://github.com/mapbox/mapbox-navigation-ios/pull/1364), [#1338](https://github.com/mapbox/mapbox-navigation-ios/pull/1338), [#1318](https://github.com/mapbox/mapbox-navigation-ios/pull/1318), [#1378](https://github.com/mapbox/mapbox-navigation-ios/pull/1378)): + * `NavigationViewControllerDelegate.navigationViewControllerDidCancelNavigation(_:)` to `NavigationViewControllerDelegate.navigationViewControllerDidDismiss(_:byCanceling:)` + * `NavigationMapViewDelegate.navigationMapView(_:shapeDescribing:)` to `NavigationMapViewDelegate.navigationMapView(_:shapeFor:)`. + * `NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeDescribing:)` to `NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeFor:)`. + * `-[MBNavigationMapViewDelegate navigationMapView:shapeDescribingWaypoints:legIndex:]` to `-[MBNavigationMapViewDelegate navigationMapView:shapeForWaypoints:legIndex:]` in Objective-C. ## v0.16.2 (April 13, 2018) diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index 0d4b3afd55..eb61e2f26e 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -426,8 +426,8 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { guard let style = style else { return } guard let activeRoute = routes.first else { return } - let mainPolyline = navigationMapDelegate?.navigationMapView?(self, shapeDescribing: activeRoute) ?? shape(describing: activeRoute, legIndex: legIndex) - let mainPolylineSimplified = navigationMapDelegate?.navigationMapView?(self, simplifiedShapeDescribing: activeRoute) ?? shape(describingCasing: activeRoute, legIndex: legIndex) + let mainPolyline = navigationMapDelegate?.navigationMapView?(self, shapeFor: activeRoute) ?? shape(for: activeRoute, legIndex: legIndex) + let mainPolylineSimplified = navigationMapDelegate?.navigationMapView?(self, simplifiedShapeFor: activeRoute) ?? shape(forCasingOf: activeRoute, legIndex: legIndex) if let source = style.source(withIdentifier: sourceIdentifier) as? MGLShapeSource, let sourceSimplified = style.source(withIdentifier: sourceCasingIdentifier) as? MGLShapeSource { @@ -811,7 +811,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { return candidates } - func shape(describing route: Route, legIndex: Int?) -> MGLShape? { + func shape(for route: Route, legIndex: Int?) -> MGLShape? { guard let coordinates = route.coordinates else { return nil } var linesPerLeg: [[MGLPolylineFeature]] = [] @@ -819,11 +819,11 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { for (index, leg) in route.legs.enumerated() { // If there is no congestion, don't try and add it guard let legCongestion = leg.segmentCongestionLevels else { - return shape(describingCasing: route, legIndex: legIndex) + return shape(forCasingOf: route, legIndex: legIndex) } guard legCongestion.count + 1 <= coordinates.count else { - return shape(describingCasing: route, legIndex: legIndex) + return shape(forCasingOf: route, legIndex: legIndex) } // The last coord of the preceding step, is shared with the first coord of the next step. @@ -871,7 +871,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { return MGLShapeCollectionFeature(shapes: Array(linesPerLeg.joined())) } - func shape(describingCasing route: Route, legIndex: Int?) -> MGLShape? { + func shape(forCasingOf route: Route, legIndex: Int?) -> MGLShape? { var linesPerLeg: [MGLPolylineFeature] = [] for (index, leg) in route.legs.enumerated() { @@ -1150,23 +1150,23 @@ public protocol NavigationMapViewDelegate: class { /** Asks the receiver to return an MGLShape that describes the geometry of the route. - - note: The returned value represents the route in full detail. For example, individual `MGLPolyline` objects in an `MGLShapeCollectionFeature` object can represent traffic congestion segments. For improved performance, you should also implement `navigationMapView(_:simplifiedShapeDescribing:)`, which defines the overall route as a single feature. + - note: The returned value represents the route in full detail. For example, individual `MGLPolyline` objects in an `MGLShapeCollectionFeature` object can represent traffic congestion segments. For improved performance, you should also implement `navigationMapView(_:simplifiedShapeFor:)`, which defines the overall route as a single feature. - parameter mapView: The NavigationMapView. - parameter route: The route that the sender is asking about. - returns: Optionally, a `MGLShape` that defines the shape of the route, or `nil` to use default behavior. */ - @objc(navigationMapView:shapeDescribing:) - optional func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape? + @objc(navigationMapView:shapeForRoute:) + optional func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape? /** Asks the receiver to return an MGLShape that describes the geometry of the route at lower zoomlevels. - - note: The returned value represents the simplfied route. It is designed to be used with `navigationMapView(_:shapeDescribing:), and if used without its parent method, can cause unexpected behavior. + - note: The returned value represents the simplfied route. It is designed to be used with `navigationMapView(_:shapeFor:), and if used without its parent method, can cause unexpected behavior. - parameter mapView: The NavigationMapView. - parameter route: The route that the sender is asking about. - returns: Optionally, a `MGLShape` that defines the shape of the route at lower zoomlevels, or `nil` to use default behavior. */ - @objc(navigationMapView:simplifiedShapeDescribing:) - optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape? + @objc(navigationMapView:simplifiedShapeForRoute:) + optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape? /** Asks the receiver to return an MGLShape that describes the geometry of the waypoint. @@ -1174,7 +1174,7 @@ public protocol NavigationMapViewDelegate: class { - parameter waypoints: The waypoints to be displayed on the map. - returns: Optionally, a `MGLShape` that defines the shape of the waypoint, or `nil` to use default behavior. */ - @objc(navigationMapView:shapeFor:legIndex:) + @objc(navigationMapView:shapeForWaypoints:legIndex:) optional func navigationMapView(_ mapView: NavigationMapView, shapeFor waypoints: [Waypoint], legIndex: Int) -> MGLShape? /** @@ -1183,7 +1183,7 @@ public protocol NavigationMapViewDelegate: class { - parameter annotation: The annotation to be styled. - returns: Optionally, a `MGLAnnotationImage` that defines the image used for the annotation. */ - @objc(navigationMapView:imageFor:) + @objc(navigationMapView:imageForAnnotation:) optional func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? /** @@ -1192,7 +1192,7 @@ public protocol NavigationMapViewDelegate: class { - parameter annotation: The annotation to be styled. - returns: Optionally, a `MGLAnnotationView` that defines the view used for the annotation. */ - @objc(navigationMapView:viewFor:) + @objc(navigationMapView:viewForAnnotation:) optional func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? /** diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 5fb71038de..c7b8b03e59 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -92,14 +92,16 @@ public protocol NavigationViewControllerDelegate { If this method is unimplemented, the navigation map view represents the route line using an `MGLPolylineFeature` based on `route`’s `coordinates` property. */ - @objc optional func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape? + @objc(navigationMapView:shapeForRoute:) + optional func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape? /** Returns an `MGLShape` that represents the path of the route line’s casing. - If this method is unimplemented, the navigation map view represents the route line’s casing using an `MGLPolylineFeature` identical to the one returned by `navigationMapView(_:shapeDescribing:)`. + If this method is unimplemented, the navigation map view represents the route line’s casing using an `MGLPolylineFeature` identical to the one returned by `navigationMapView(_:shapeFor:)`. */ - @objc optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape? + @objc(navigationMapView:simplifiedShapeForRoute:) + optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape? /* Returns an `MGLStyleLayer` that marks the location of each destination along the route when there are multiple destinations. The returned layer is added to the map below the layer returned by `navigationMapView(_:waypointSymbolStyleLayerWithIdentifier:source:)`. @@ -478,12 +480,12 @@ extension NavigationViewController: RouteMapViewControllerDelegate { delegate?.navigationMapView?(mapView, didTap: route) } - @objc public func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape? { - return delegate?.navigationMapView?(mapView, shapeDescribing: route) + @objc public func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape? { + return delegate?.navigationMapView?(mapView, shapeFor: route) } - @objc public func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape? { - return delegate?.navigationMapView?(mapView, shapeDescribing: route) + @objc public func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape? { + return delegate?.navigationMapView?(mapView, shapeFor: route) } public func navigationMapView(_ mapView: NavigationMapView, waypointStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? { diff --git a/MapboxNavigation/RouteMapViewController.swift b/MapboxNavigation/RouteMapViewController.swift index 95c10053a3..49a85be87d 100644 --- a/MapboxNavigation/RouteMapViewController.swift +++ b/MapboxNavigation/RouteMapViewController.swift @@ -671,16 +671,16 @@ extension RouteMapViewController: NavigationViewDelegate { return delegate?.navigationMapView?(mapView, shapeFor: waypoints, legIndex: legIndex) } - func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape? { - return delegate?.navigationMapView?(mapView, shapeDescribing: route) + func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape? { + return delegate?.navigationMapView?(mapView, shapeFor: route) } func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) { delegate?.navigationMapView?(mapView, didSelect: route) } - func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape? { - return delegate?.navigationMapView?(mapView, simplifiedShapeDescribing: route) + func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape? { + return delegate?.navigationMapView?(mapView, simplifiedShapeFor: route) } func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {