From 036a0c9820bb04df969eb940c77a64c97487f94e Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Fri, 23 Mar 2018 10:37:05 -0700 Subject: [PATCH 1/3] Fix custom image for annotation --- MapboxNavigation/NavigationMapView.swift | 18 ++++++++++++++++++ .../NavigationViewController.swift | 2 +- MapboxNavigation/RouteMapViewController.swift | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index 57dd1a6ab5..439781fa40 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -1209,6 +1209,24 @@ public protocol NavigationMapViewDelegate: class { @objc(navigationMapView:shapeDescribingWaypoints:) optional func navigationMapView(_ mapView: NavigationMapView, shapeFor waypoints: [Waypoint]) -> MGLShape? + /** + Asks the receiver to return an MGLAnnotationImage that describes the image used an annotation. + - parameter mapView: The MGLMapView. + - parameter annotation: The annotation to be styled. + - returns: Optionally, a `MGLAnnotationImage` that defines the image used for the annotation. + */ + @objc(navigationMapView:imageForAnnotation:) + optional func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? + + /** + Asks the receiver to return an MGLAnnotationView that describes the image used an annotation. + - parameter mapView: The MGLMapView. + - parameter annotation: The annotation to be styled. + - returns: Optionally, a `MGLAnnotationView` that defines the view used for the annotation. + */ + @objc(navigationMapView:viewForAnnotation:) + optional func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? + /** Asks the receiver to return a CGPoint to serve as the anchor for the user icon. - important: The return value should be returned in the normal UIKit coordinate-space, NOT CoreAnimation's unit coordinate-space. diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 3f38e4c521..4019462c32 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -492,7 +492,7 @@ extension NavigationViewController: RouteMapViewControllerDelegate { return delegate?.navigationMapView?(mapView, shapeFor: waypoints) } - func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? { + public func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? { return delegate?.navigationMapView?(mapView, imageFor: annotation) } diff --git a/MapboxNavigation/RouteMapViewController.swift b/MapboxNavigation/RouteMapViewController.swift index fd8d907da8..27e7dd2548 100644 --- a/MapboxNavigation/RouteMapViewController.swift +++ b/MapboxNavigation/RouteMapViewController.swift @@ -649,11 +649,11 @@ extension RouteMapViewController: NavigationViewDelegate { } func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? { - return delegate?.mapView?(mapView, imageFor :annotation) + return delegate?.navigationMapView?(mapView, imageFor: annotation) } func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? { - return delegate?.mapView?(mapView, viewFor: annotation) + return delegate?.navigationMapView?(mapView, viewFor: annotation) } func navigationMapViewUserAnchorPoint(_ mapView: NavigationMapView) -> CGPoint { From 158ad99760d322231579b3b822dc078c7875cc7a Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Fri, 23 Mar 2018 10:39:51 -0700 Subject: [PATCH 2/3] also public --- MapboxNavigation/NavigationViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 4019462c32..2fbdf4d20b 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -496,7 +496,7 @@ extension NavigationViewController: RouteMapViewControllerDelegate { return delegate?.navigationMapView?(mapView, imageFor: annotation) } - func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? { + public func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? { return delegate?.navigationMapView?(mapView, viewFor: annotation) } From 6ee83dd3e2890e9f876ac5189250d08f1cdff403 Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Fri, 23 Mar 2018 12:08:01 -0700 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d778a14be9..04bd472ab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Fixed an issue causing the overview map to insist on centering the route upon each location update. ([#1223](https://github.com/mapbox/mapbox-navigation-ios/pull/1223)) * Improved the contrast of `TimeRemainingLabel.trafficSevereColor` against `BottomBannerView.backgroundColor` in `NightStyle`. ([#1228](https://github.com/mapbox/mapbox-navigation-ios/pull/1228)) * Fixed an issue where a slash appeared between two shields in the top banner. ([#1169](https://github.com/mapbox/mapbox-navigation-ios/pull/1169)) +* Fixed an issue where using `NavigationMapViewControllerDelegate.navigationMapView(_:imageFor:)` would not override the destination annotation. [#1256](https://github.com/mapbox/mapbox-navigation-ios/pull/1256) ### Spoken instructions * Audio data for spoken instructions is cached in device storage to minimize data usage. ([#12296](https://github.com/mapbox/mapbox-navigation-ios/pull/1226))