From 9ba5f6840660be766465b0a89db3d023c5263c4e Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Fri, 23 Mar 2018 12:21:00 -0700 Subject: [PATCH] Fix custom image for annotation (#1256) --- CHANGELOG.md | 1 + MapboxNavigation/NavigationMapView.swift | 18 ++++++++++++++++++ .../NavigationViewController.swift | 4 ++-- MapboxNavigation/RouteMapViewController.swift | 4 ++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d778a14be93..04bd472ab31 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)) diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index 57dd1a6ab59..439781fa404 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 3f38e4c5219..2fbdf4d20b7 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -492,11 +492,11 @@ 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) } - func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? { + public func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? { return delegate?.navigationMapView?(mapView, viewFor: annotation) } diff --git a/MapboxNavigation/RouteMapViewController.swift b/MapboxNavigation/RouteMapViewController.swift index fd8d907da85..27e7dd2548c 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 {