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

Custom Route shapes fix #2623

Merged
merged 2 commits into from
Oct 28, 2020
Merged

Custom Route shapes fix #2623

merged 2 commits into from
Oct 28, 2020

Conversation

Udumft
Copy link
Contributor

@Udumft Udumft commented Sep 14, 2020

Fixes #2595

Restored calling NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeFor:) method for shape customization and verified that custom shapes mechanism works.

There is a discussion going on around these methods on how to improve the API and make customization easy and straightforward. Eventually we should remove these methods, but decided to leave them for now because there is no alternative ideas developed atm and some clients already use that API.

@Udumft Udumft added bug Something isn’t working topic: cartography Regression labels Sep 14, 2020
@Udumft Udumft added this to the v1.1.0 milestone Sep 14, 2020
@Udumft Udumft self-assigned this Sep 14, 2020
@@ -473,7 +473,8 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
let allRoutesShape = navigationMapViewDelegate?.navigationMapView(self, shapeFor: routes) ?? shape(for: routes, legIndex: legIndex)
let allRoutesSource = addAllRoutesSource(style, shape: allRoutesShape)

let mainRouteCasingShape = navigationMapViewDelegate?.navigationMapView(self, shapeFor: [mainRoute]) ?? shape(for: [mainRoute], legIndex: legIndex)
let mainRouteCasingShape = navigationMapViewDelegate?.navigationMapView(self, simplifiedShapeFor: mainRoute) ?? shape(forCasingOf: mainRoute, legIndex: legIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should allRoutesShape also call navigationMapView(_:simplifiedShapeFor:)? What should call navigationMapView(_:shapeFor:)? Previously, a developer would’ve implemented navigationMapView(_:shapeFor:) to provide the shape data for the whole route (normally to be used as the casing) and navigationMapView(_:simplifiedShapeFor:) to provide the shape data for the route broken up by arbitrary segments (normally to be colored by traffic congestion).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I found in the code, navigationMapView(_:shapeFor:) is meant to provide route shapes, and navigationMapView(_:simplifiedShapeFor:) meant to provide the casing shape. At least when I provided my custom Shapes like that they were colored as route and casing respectfully. Even if my custom shape for navigationMapView(_:shapeFor:) had just one Polyline it still was colored with congestion segments.
Doesn't it supposed to be like that?

Copy link
Contributor

Choose a reason for hiding this comment

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

As I found in the code, navigationMapView(_:shapeFor:) is meant to provide route shapes, and navigationMapView(_:simplifiedShapeFor:) meant to provide the casing shape.

Yes, sorry, I got the two methods mixed up in #2623 (comment). If you provide only one shape in navigationMapView(_:shapeFor:), I don’t think there should be colored congestion segments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So... Is this convo resolved? :)

@Udumft Udumft requested a review from 1ec5 October 5, 2020 10:29
@1ec5 1ec5 changed the base branch from master to main October 7, 2020 18:19
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

Remember to add a changelog entry about restoring the ability to customize the route shape.

@Udumft Udumft merged commit 4c4a33b into main Oct 28, 2020
@Udumft Udumft deleted the vk/2595-custom-route-shape branch October 28, 2020 07:14
@MaximAlien
Copy link
Contributor

MaximAlien commented Oct 28, 2020

@1ec5, @Udumft After merging this PR to main I can see that route casing is no longer present:

Screen Shot 2020-10-28 at 3 28 10 PM

Before route line casing was visible:

Screen Shot 2020-10-28 at 3 28 37 PM

When I check shape(forCasingOf:legIndex:) implementation I see that MGLPolylineFeature doesn't use isAlternateRoute. Since shape(forCasingOf:legIndex:) is called only main route line in default case shouldn't we set polyline.attributes["isAlternateRoute"] = false?

We should also update changelog with newly added fix.

@Udumft
Copy link
Contributor Author

Udumft commented Oct 29, 2020

Shame on me for missing this one :( but thank you for pointing that out! Fix submitted in mapbox/mapbox-navigation-ios/pull/2715

Copy link

@Rmkasun-8 Rmkasun-8 left a comment

Choose a reason for hiding this comment

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

Navigation on mapview

Copy link

@Rmkasun-8 Rmkasun-8 left a comment

Choose a reason for hiding this comment

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

Change

Copy link

@Rmkasun-8 Rmkasun-8 left a comment

Choose a reason for hiding this comment

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

Authored

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to provide custom route line shapes
5 participants