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

Fix custom image for annotation #1256

Merged
merged 3 commits into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
18 changes: 18 additions & 0 deletions MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, this implements part of #685 but takes us further away from being able to allow the developer to just use any MGLMapViewDelegate method, as suggested in #685 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree, however lets make the breaking change for all methods in a single pr.


/**
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.
Expand Down
4 changes: 2 additions & 2 deletions MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions MapboxNavigation/RouteMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down